From b3cd7bd626aee278b025e97e6023447f28216085 Mon Sep 17 00:00:00 2001 From: SaltedCaramelCoffee <10778821+SaltedCaramelCoffee@users.noreply.github.com> Date: Thu, 12 Mar 2026 00:57:42 -0700 Subject: [PATCH] Fix interaction reply race conditions in skip, unskip, seek, replay, resume --- src/commands/replay.ts | 6 ++---- src/commands/resume.ts | 3 ++- src/commands/seek.ts | 6 ++---- src/commands/skip.ts | 3 ++- src/commands/unskip.ts | 3 ++- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/commands/replay.ts b/src/commands/replay.ts index 068158acb..b2d8af333 100644 --- a/src/commands/replay.ts +++ b/src/commands/replay.ts @@ -32,10 +32,8 @@ export default class implements Command { throw new Error('can\'t replay a livestream'); } - await Promise.all([ - player.seek(0), - interaction.deferReply(), - ]); + await interaction.deferReply(); + await player.seek(0); await interaction.editReply('👍 replayed the current song'); } diff --git a/src/commands/resume.ts b/src/commands/resume.ts index 2e1514a4d..d4952ea1e 100644 --- a/src/commands/resume.ts +++ b/src/commands/resume.ts @@ -34,10 +34,11 @@ export default class implements Command { throw new Error('nothing to play'); } + await interaction.deferReply(); await player.connect(targetVoiceChannel); await player.play(); - await interaction.reply({ + await interaction.editReply({ content: 'the stop-and-go light is now green', embeds: [buildPlayingMessageEmbed(player)], }); diff --git a/src/commands/seek.ts b/src/commands/seek.ts index 97d6a9810..ba7138a62 100644 --- a/src/commands/seek.ts +++ b/src/commands/seek.ts @@ -53,10 +53,8 @@ export default class implements Command { throw new Error('can\'t seek past the end of the song'); } - await Promise.all([ - player.seek(seekTime), - interaction.deferReply(), - ]); + await interaction.deferReply(); + await player.seek(seekTime); await interaction.editReply(`👍 seeked to ${prettyTime(player.getPosition())}`); } diff --git a/src/commands/skip.ts b/src/commands/skip.ts index df681ed9f..15f0ca600 100644 --- a/src/commands/skip.ts +++ b/src/commands/skip.ts @@ -34,8 +34,9 @@ export default class implements Command { const player = this.playerManager.get(interaction.guild!.id); try { + await interaction.deferReply(); await player.forward(numToSkip); - await interaction.reply({ + await interaction.editReply({ content: 'keep \'er movin\'', embeds: player.getCurrent() ? [buildPlayingMessageEmbed(player)] : [], }); diff --git a/src/commands/unskip.ts b/src/commands/unskip.ts index d7d7644be..28a99328c 100644 --- a/src/commands/unskip.ts +++ b/src/commands/unskip.ts @@ -24,8 +24,9 @@ export default class implements Command { const player = this.playerManager.get(interaction.guild!.id); try { + await interaction.deferReply(); await player.back(); - await interaction.reply({ + await interaction.editReply({ content: 'back \'er up\'', embeds: player.getCurrent() ? [buildPlayingMessageEmbed(player)] : [], });