fix(media): publish status when a track ends naturally

The Redis media:status key was only rewritten after a command received via
Redis. When the last track ended naturally (AudioPlayer Idle -> advanceQueue
with an empty queue), currentTrackItem was cleared but the status key was not
persisted — so the backend's cached status and the frontend's 10s polling
stayed stuck showing the finished track as 'playing' forever.

Wire a media-status sink (commandHandler provides the real redisPub to
MediaHandler) and re-publish status after auto-advance, so natural track end
updates the UI.
This commit is contained in:
asepharyana
2026-08-02 10:43:34 +07:00
parent ef4281cd1f
commit dbcf9d68f2
3 changed files with 73 additions and 4 deletions
@@ -16,6 +16,7 @@ import {
createHandlerRegistry,
} from "./handler-registry.js";
import { MediaHandler } from "./media.handler.js";
import { wireMediaStatusWriter } from "./mediaStatusSink.js";
import { ModerationHandler } from "./moderation.handler.js";
import { VoiceHandler } from "./voice.handler.js";
@@ -88,6 +89,10 @@ export class CommandHandler {
this.guildHandler = new GuildHandler(client);
this.moderationHandler = new ModerationHandler(client);
// Wire the media status sink so MediaHandler can persist status on
// queue advances that happen outside a command (natural track end).
wireMediaStatusWriter(this.redisPub);
// Build the command registry
this.registry = createHandlerRegistry(
this.voiceHandler,