Repository navigation
fix(bot): prevent duplicate now-playing message from /play command #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||
| } from '../../../../utils/music/queueManipulation' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { buildPlayResponseEmbed } from '../../../../utils/music/nowPlayingEmbed' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createMusicControlButtons } from '../../../../utils/music/buttonComponents' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { registerNowPlayingMessage } from '../../../../handlers/player/trackNowPlaying' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| DISCORD_UNKNOWN_INTERACTION_CODE, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| isUnknownInteractionError, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -261,6 +262,23 @@ export default new Command({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| content: { embeds: [embed], components }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // When the track starts playing immediately (queuePosition === 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // register the interaction reply as the "now playing" message so | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // the playerStart handler edits it (adding buttons) rather than | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // sending a second "Now Playing" message in the channel. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (queuePosition === 0 && interaction.guildId) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const reply = await interaction.fetchReply() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| registerNowPlayingMessage( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| interaction.guildId, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| reply.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| reply.channelId, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // non-critical β worst case playerStart sends a fresh message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+269
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard registration to non-playlist replies to avoid overwriting playlist confirmation.
π‘ Proposed fix- if (queuePosition === 0 && interaction.guildId) {
+ if (queuePosition === 0 && !isPlaylist && interaction.guildId) {
try {
const reply = await interaction.fetchReply()
registerNowPlayingMessage(
interaction.guildId,
reply.id,
reply.channelId,
)
} catch {
// non-critical β worst case playerStart sends a fresh message
}
}π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // Start background ops (apply autoplay pref then blend) without awaiting. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // This lets the response reach the user immediately. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // The Promise is not awaited, allowing the command handler to return while | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid silent failure in registration fallback path.
The empty catch makes duplicate-message diagnostics harder when fetch/register fails intermittently. Add at least a debug/warn log.
πͺ΅ Proposed fix
As per coding guidelines, "Implement error handling and error logging".
π Committable suggestion
π€ Prompt for AI Agents