Skip to content

fix(bot): prevent duplicate now-playing message from /play command - #542

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
fix/play-duplicate-message
Apr 10, 2026
Merged

LucasSantana-Dev merged 1 commit into
mainfrom
fix/play-duplicate-message

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Apr 10, 2026 •

Copy link
Copy Markdown
Owner

Problem

When /play is used and the track starts immediately (empty queue), users see two "Now Playing" messages:

  1. The /play interaction reply — "🎵 Now Playing: [track]"
  2. A second message from the playerStart handler calling sendNowPlayingEmbed

Root cause: sendNowPlayingEmbed checks songInfoMessages (an internal Map) to decide whether to edit an existing message or send a new one. The interaction reply is never registered in that map, so the handler always sends a fresh message.

Fix

trackNowPlaying.ts — Export registerNowPlayingMessage(guildId, messageId, channelId) that writes to songInfoMessages.

play/index.ts — After sending the interaction reply when queuePosition === 0 (track starts immediately), call interaction.fetchReply() and register the reply via registerNowPlayingMessage. The playerStart handler then edits that message (refreshing buttons) rather than sending a second one.

False positive analysis

The previous play command tests never simulated the playerStart event firing, so the duplicate was invisible to the test suite. Added a regression test that explicitly verifies fetchReply is called and registerNowPlayingMessage receives the correct messageId + channelId.

Test plan

  • 1869 tests, 0 failures
  • New regression test: registers interaction reply as now-playing message to prevent duplicate
  • Manual: /play some song in empty voice channel → only ONE "Now Playing" embed appears

Summary by CodeRabbit

  • New Features

    • Prevents duplicate "now playing" messages when a track begins playback at queue position 0.
  • Tests

    • Added test coverage for now-playing message registration during track playback.

trackNowPlaying: export registerNowPlayingMessage so callers can
pre-register an existing message as the guild's now-playing display.

play/index.ts: when a track starts immediately (queuePosition === 0),
fetch the interaction reply and register it via registerNowPlayingMessage.
The playerStart handler then edits that message (adding control buttons)
instead of sending a second 'Now Playing' embed in the channel.

play/index.spec.ts: add regression test that verifies fetchReply is
called and registerNowPlayingMessage receives the reply id+channelId.
Documents the false-positive gap where playerStart was never simulated.
@vercel

vercel Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Apr 10, 2026 10:47pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds message registration to prevent duplicate "Now Playing" messages. When the /play command queues a track at position 0, it now fetches the interaction reply and pre-registers it with the message tracking system, enabling the player handler to reuse that message for edits instead of creating a new one.

Changes

Cohort / File(s) Summary
Play Command Implementation
packages/bot/src/functions/music/commands/play/index.ts
Added conditional logic to fetch the interaction reply and invoke registerNowPlayingMessage when the track is queued at position 0, wrapped in try/catch for error resilience.
Message Registration Handler
packages/bot/src/handlers/player/trackNowPlaying.ts
Added new exported function registerNowPlayingMessage that pre-populates the guild's message tracking map with an existing message identity for later reuse.
Play Command Tests
packages/bot/src/functions/music/commands/play/index.spec.ts
Extended mocks and test interaction stub to include registerNowPlayingMessage spy and fetchReply method; added test case validating message registration when queuePosition=0.

Sequence Diagram

sequenceDiagram
    participant User
    participant PlayCmd as Play Command
    participant Handler as Message Handler
    participant Player as Player Handler

    User->>PlayCmd: Execute /play command (queuePosition=0)
    PlayCmd->>PlayCmd: Send interaction reply
    PlayCmd->>Handler: Fetch interaction reply (id, channelId)
    PlayCmd->>Handler: registerNowPlayingMessage(guildId, messageId, channelId)
    Handler->>Handler: Pre-populate songInfoMessages map
    PlayCmd-->>User: Command response sent
    
    Note over Player: Later, track starts playing
    Player->>Handler: sendNowPlayingEmbed() looks up songInfoMessages
    Handler->>Handler: Finds pre-registered message
    Player->>Player: Edit existing message (no duplicate created)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bot, size/m

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(bot): prevent duplicate now-playing message from /play command' is specific, concise, and accurately describes the main change—preventing duplicate 'Now Playing' messages when using the /play command. It follows conventional commit format and clearly communicates the problem being solved.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/play-duplicate-message

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bot/src/functions/music/commands/play/index.ts`:
- Around line 277-279: The empty catch in the play command's registration
fallback swallows errors; change it to catch the error (e.g., catch (err)) and
log a debug/warn message including the error stack and contextual identifiers
(guildId, userId, trackId or similar) so duplicate-message diagnostics are
possible; update the catch inside the play command (the block around
playerStart/fallback registration) to call the existing logger (processLogger or
logger) with a clear message and the error object.
- Around line 269-280: When queuePosition === 0 you must avoid registering the
playlist-queued confirmation as the now-playing message; change the block around
interaction.fetchReply() and registerNowPlayingMessage(...) to first detect and
skip playlist-start replies (e.g., check a flag/option that indicates a playlist
start or inspect the fetched reply content/components to ensure it is not the
playlistQueued confirmation) and only call registerNowPlayingMessage when the
reply is the actual now-playing message (keep references to queuePosition,
interaction.fetchReply, and registerNowPlayingMessage to locate the code).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0380cf58-28c9-46bc-9df6-84cac340ed1c

📥 Commits

Reviewing files that changed from the base of the PR and between 1043e5b and 3b53f8a.

📒 Files selected for processing (3)
  • packages/bot/src/functions/music/commands/play/index.spec.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/handlers/player/trackNowPlaying.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: SonarCloud Scan
  • GitHub Check: Quality Gates
🧰 Additional context used
📓 Path-based instructions (20)
**/*.{js,jsx,ts,tsx,vue,html}

📄 CodeRabbit inference engine (.cursor/rules/accessibility-openness.mdc)

Provide accessible UI components using semantic HTML and ARIA attributes where necessary

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/dependency-injection.mdc)

**/*.{ts,tsx,js,jsx}: Prefer constructor injection for classes that require dependencies
Avoid global mutable singletons unless necessary
Use explicit interfaces for external dependencies to make testing easier

**/*.{ts,tsx,js,jsx}: Include required references in PRs/code for non-trivial logic: TypeScript (official docs), MDN (JavaScript reference), and official docs for any runtime/framework/libraries used (e.g., Node.js, React) as applicable.
Before assuming behavior of an API, include the doc link and a ≤25-word quote when the change relies on it.

**/*.{ts,tsx,js,jsx}: Prefer named exports for clear usage and easier refactors in TypeScript/JavaScript
Keep import order consistent: external first, then internal modules
Remove dead code and unused imports

**/*.{ts,tsx,js,jsx}: Use PascalCase naming convention for React/UI components
Use camelCase naming convention for variables and functions
Use UPPER_SNAKE_CASE naming convention for constants
Maintain consistent import grouping and ordering within the project, keeping third-party imports separate from local imports
For external data sources (HTTP, database), always validate and sanitize input using type guards or schema validators

Implement TypeScript typecheck and linter in CI quality checks

**/*.{ts,tsx,js,jsx}: Use TypeScript for enhanced type safety
Implement error handling and error logging
Avoid commenting code unless extremely necessary - code should explain itself with descriptive names
Leave NO todos, placeholders or missing pieces in the code
Variables and functions must use camelCase
Constants must use UPPER_SNAKE_CASE
Use arrow functions for methods and computed properties
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
Maintain consistent import grouping/order: external imports first, then internal modules
Use named exports for clear usage and easier refactors
Always validate and sanitize external data (HTTP, DB) at the boundary using type guards ...

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

**/*.{js,jsx,ts,tsx}: Never throw strings. Throw Error (or typed subclasses) with descriptive messages
Include causal error as cause when available for better debugging
Define clear, stable error codes (e.g., ERR_AUTH_EXPIRED, ERR_NETWORK_TIMEOUT)
Provide optional metadata (e.g., details, retryable, status, correlationId) in error objects
Use domain error classes per area (e.g., AuthenticationError, ValidationError, NetworkError)
Log errors with structure (message, code, stack, cause, correlationId, user context where appropriate)
Mark retryable vs nonRetryable errors where helpful for operations
Set timeouts and handle aborts/cancellations; avoid dangling requests in API/network code
Implement backoff for transient failures; avoid infinite retries
Map HTTP status → domain errors; 4xx vs 5xx behave differently (e.g., retry for 5xx/network)

**/*.{js,jsx,ts,tsx}: Use functional components with hooks in React/React Native. Avoid class components.
Keep components focused on a single responsibility; extract complex logic into custom hooks.
Keep state local when possible. Use Context/Zustand/Redux only when necessary for state management.
If props or state traverse more than 3 levels, consider using context or a feature-scoped store instead of prop drilling.
Use performance optimization techniques: React.memo, useMemo, useCallback, Suspense (web), and virtualization for long lists; avoid unnecessary re-renders.
Web accessibility: use semantic HTML, labels, focus management, keyboard navigation, and aria-* attributes as needed.
React Native accessibility: use accessibility props (accessible, accessibilityLabel), proper roles and labels.
Identify and extract repetitive UI components proactively to components/ with clear props and minimal coupling.
Web styles: prefer co-located styles or design system tokens; avoid global style leakage.
React Native styles: prefer StyleSheet.create, design tokens, and theme providers; avoid in...

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

Introduce interfaces at module boundaries to enable testing and substitutions

**/*.{ts,tsx}: Avoid using any type in TypeScript. If unavoidable, use unknown with type guards and justify with a code comment
Prefer interface for defining public object shapes in TypeScript, use type for unions and utility types
Use TypeScript utility types such as Partial, Pick, Omit, Readonly, and Record when appropriate
Use I{Name} naming convention for interfaces in TypeScript
Use T{Name} naming convention for type aliases and utility types in TypeScript

**/*.{ts,tsx}: Prefer types over interfaces for most cases
Don't ever use any - type safety always
Avoid enums; use const objects instead
For complex types, create a separate file to declare them and import them
Avoid using any type; if unavoidable, use unknown with type guards and justify with code comment
Prefer interface for public API shapes; use type for unions and utility types
Use TypeScript utility types (Partial, Pick, Omit, Readonly, Record)

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/documentation.mdc)

**/*.{js,ts,tsx,jsx}: Minimize comments in code; explain the 'why' when non-obvious, let code express the 'what' through clear naming
Document trade-offs briefly when deviating from ideal patterns

**/*.{js,ts,tsx,jsx}: Store secrets, ports, and hosts in environment variables (.env, .env.example) and never hardcode them
Avoid redundant or decorative AI comments; code should be self-explanatory and only commented when logic is non-obvious; prefer refactoring over lengthy comments

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
packages/bot/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

packages/bot/**/*.{ts,tsx}: Use useMainPlayer() from discord-player to access the player instance; do not instantiate player directly
Do not duplicate queue or player state outside Discord Player; use shared services from @lucky/shared for persistent data like track history and session information
Use errorLog and debugLog from @lucky/shared/utils for logging throughout the bot package
Use embed and reply utilities from @lucky/shared for consistent message formatting and error sanitization across the bot
Use services from @lucky/shared (DatabaseService, Redis client) for database and cache access; do not instantiate Prisma or Redis directly in the bot package

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
packages/bot/src/handlers/player/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

Track handling, errors, and lifecycle must be managed through dedicated handlers in packages/bot/src/handlers/player/ (trackHandlers, errorHandlers, lifecycleHandlers)

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
packages/bot/**

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

The bot package depends on shared and contains Discord bot commands and player handlers using Discord.js and Discord Player

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{js,mjs,ts,mts}

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

Use Node.js version ≥22 with ESM (ECMAScript modules) only; no CommonJS

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
packages/bot/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

Use @lucky/shared for database, Redis, logging, and embed utilities instead of implementing them locally

Files:

  • packages/bot/src/handlers/player/trackNowPlaying.ts
  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

Use index.ts only to re-export a small, intentional surface per module

Files:

  • packages/bot/src/functions/music/commands/play/index.ts
packages/bot/src/functions/*/commands/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

packages/bot/src/functions/*/commands/**/*.{ts,tsx}: Command model must include data (slash builder), execute, and category properties exported from packages/bot/src/models/Command.ts
Use @discordjs/builders for building the data (SlashCommandBuilder) in command definitions
Command execute function must receive { interaction, client } parameters from CommandExecuteParams type
Use interactionReply and createUserFriendlyError utilities from @lucky/shared/general utils for command replies and error handling
Use existing validators from packages/bot/src/utils/command/ for voice channel, queue, and guild validations in commands

Files:

  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
packages/bot/src/functions/{general,music,download}/commands/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

packages/bot/src/functions/{general,music,download}/commands/**/*.ts: Apply .cursor/rules/lucky-discord-bot.mdc rules for Discord bot commands and player implementation
Use .cursor/skills/discord-commands/SKILL.md for implementing slash commands

Files:

  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
packages/bot/src/functions/music/commands/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

Use .cursor/skills/music-queue-player/SKILL.md for play, queue, skip, volume commands and player lifecycle management

Files:

  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
packages/bot/src/functions/music/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

Use existing voice/queue/guild validators before manipulating player or queue state

Files:

  • packages/bot/src/functions/music/commands/play/index.ts
  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Test behavior, not implementation. Prefer Testing Library utilities for testing React/React Native components.
For React Native tests: mock native modules and test component interactions and accessibility labels.

Files:

  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Test behavior, not implementation details
Prefer unit tests for core logic; add integration tests at meaningful boundaries

Files:

  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/testing-quality.mdc)

**/*.{test,spec}.{js,ts,jsx,tsx}: Use Jest + a React testing library for unit and component tests as applicable
Test behavior, not implementation details

Files:

  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.{spec,test}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/quality.mdc)

**/*.{spec,test}.{ts,tsx,js,jsx}: Use Jest for unit and integration tests
Test behavior, not implementation details
Run unit, integration tests, and coverage report in CI quality checks

Files:

  • packages/bot/src/functions/music/commands/play/index.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/quality.mdc)

Unit tests must use naming convention *.spec.ts

Files:

  • packages/bot/src/functions/music/commands/play/index.spec.ts
🔇 Additional comments (2)
packages/bot/src/handlers/player/trackNowPlaying.ts (1)

32-38: Clean abstraction for pre-registering now-playing messages.

Good addition—this keeps the map mutation encapsulated and enables /play to reuse/edit the existing message path cleanly.

packages/bot/src/functions/music/commands/play/index.spec.ts (1)

733-780: Solid regression coverage for the duplicate-now-playing path.

This test correctly validates the new registration flow by asserting fetchReply() and the exact registerNowPlayingMessage(guildId, messageId, channelId) call.

Comment on lines +269 to +280
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
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard registration to non-playlist replies to avoid overwriting playlist confirmation.

queuePosition === 0 is also true for an empty-queue playlist start. In that case, this registers the playlistQueued reply, and playerStart may overwrite that message with now-playing content.

💡 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
}
}
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
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bot/src/functions/music/commands/play/index.ts` around lines 269 -
280, When queuePosition === 0 you must avoid registering the playlist-queued
confirmation as the now-playing message; change the block around
interaction.fetchReply() and registerNowPlayingMessage(...) to first detect and
skip playlist-start replies (e.g., check a flag/option that indicates a playlist
start or inspect the fetched reply content/components to ensure it is not the
playlistQueued confirmation) and only call registerNowPlayingMessage when the
reply is the actual now-playing message (keep references to queuePosition,
interaction.fetchReply, and registerNowPlayingMessage to locate the code).

Comment on lines +277 to +279
} catch {
// non-critical — worst case playerStart sends a fresh message
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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
-                } catch {
-                    // non-critical — worst case playerStart sends a fresh message
+                } catch (error) {
+                    debugLog({
+                        message: 'Failed to register now-playing interaction reply',
+                        error,
+                        data: { guildId: interaction.guildId },
+                    })
                 }

As per coding guidelines, "Implement error handling and error logging".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch {
// non-critical — worst case playerStart sends a fresh message
}
} catch (error) {
debugLog({
message: 'Failed to register now-playing interaction reply',
error,
data: { guildId: interaction.guildId },
})
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bot/src/functions/music/commands/play/index.ts` around lines 277 -
279, The empty catch in the play command's registration fallback swallows
errors; change it to catch the error (e.g., catch (err)) and log a debug/warn
message including the error stack and contextual identifiers (guildId, userId,
trackId or similar) so duplicate-message diagnostics are possible; update the
catch inside the play command (the block around playerStart/fallback
registration) to call the existing logger (processLogger or logger) with a clear
message and the error object.

@LucasSantana-Dev
LucasSantana-Dev merged commit 60aa6b0 into main Apr 10, 2026
12 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the fix/play-duplicate-message branch April 10, 2026 22:51
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
)

trackNowPlaying: export registerNowPlayingMessage so callers can
pre-register an existing message as the guild's now-playing display.

play/index.ts: when a track starts immediately (queuePosition === 0),
fetch the interaction reply and register it via registerNowPlayingMessage.
The playerStart handler then edits that message (adding control buttons)
instead of sending a second 'Now Playing' embed in the channel.

play/index.spec.ts: add regression test that verifies fetchReply is
called and registerNowPlayingMessage receives the reply id+channelId.
Documents the false-positive gap where playerStart was never simulated.

This branch was successfully deployed

1 active deployment
Preview — 3b53f8a7 Deployed Apr 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant