Repository navigation
fix(bot): reliable /play acknowledgment and a session-scoped queue - #9
Merged
Merged
Conversation
The pending queue belongs to one voice session, so leaving the channel has to delete it. clearPendingQueue removes only `played = false` rows of one room and the votes attached to them, in one transaction, and leaves played history and other rooms untouched. Tested against the real migrations.
Discord expires an unanswered interaction after three seconds, so a command cannot wait for database or yt-dlp work before acknowledging. The policy maps every registered command to its ephemeral/public reply, and the test fails if a command is ever added without one.
/play could answer after Discord's three-second window — the approval lookup and the rememberUser upsert ran before deferReply, and either can wait on SQLite's busy timeout — and the late reply failed with 10062 'Unknown interaction', losing the command. Every slash command is now deferred before the first await and every slash branch answers through editReply. Leaving voice now also ends the queue: leaveVoice tears the guild down and deletes the room's pending songs and their votes, on the automatic reap, a failed reconnect, /stop, guild removal and shutdown. /stop reports the count. The reaper skips a guild while a play request or advance is in flight, a destroyed/disconnected connection is replaced instead of reused, a stale Disconnected handler cannot tear down a newer connection, and /play says when the track was queued but playback did not start.
README states that leaving the channel clears the room's pending songs and votes, that /stop does the same, and that /reset only revives history inside the current session. The ODD record keeps the specs, the checks and the one piece of proof that is missing: the independent verification run failed without a report.
This was referenced Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/ack.ts./stop, guild removal, shutdown) clears the room's pending songs and their votes. Played history stays./playor an advance is in flight, and/playreports when a song was queued but playback did not start.Changes
packages/server/src/lib/pendingQueue.tsclearPendingQueue: deletesplayed = falserows and their votes in one transactionpackages/server/src/lib/ack.tsephemeralNotice(private answer after a public defer, without leaving the placeholder hanging)packages/server/src/index.tsleaveVoiceon every leave path, reaper race guards, stale-session cleanup before/playinsertsREADME.md/stopbehaviorodd/tasks/queue-reset-on-leave.mdTest plan
bun test: 71 pass, 0 fail (new cases inack.test.tsandpendingQueue.test.ts)bun build src/index.ts --target bun: exit 0/playwith a URL,/stop, a dropped voice connection followed by/play, and the permission denials on/stopand/resetReview note
The branch is about 640 changed lines. Review it as one unit;
e7bee73(interaction and leave wiring) andfb02450(review fixes) deserve the closest look.