fix(voice): self-undeafen/self-unmute bot instantly on server mute/deafen

Previously forceSelfServerUnmuteUndeafen only ran on video-watch attempts and
after voice reconnects — so when an admin server-muted or server-deafened the
bot, it stayed muted/deafened for minutes (or forever if no streamer came on).

Add registerSelfVoiceStateGuard: a voiceStateUpdate listener that detects the
bot's own serverMute/serverDeaf transition to true and immediately re-issues
mute:false,deaf:false. Wired at client-ready in bootstrap.ts. Best-effort,
idempotent, never blocks the gateway.
This commit is contained in:
asepharyana
2026-09-02 00:30:57 +07:00
parent 82f1698043
commit dd9f2f6bbc
2 changed files with 69 additions and 1 deletions
@@ -36,6 +36,7 @@ import { registerPresenceCapture } from "../modules/user-presence/index.js";
import { VoicePcmWsClient } from "../modules/voice-pcm-ws/index.js";
import { startMuxerWorker } from "../modules/voice-recording/muxer.js";
import {
registerSelfVoiceStateGuard,
setPcmWsClient,
setEventBroadcaster as setRecorderEventBroadcaster,
} from "../modules/voice-recording/recorder.js";
@@ -298,6 +299,12 @@ export async function initializeDiscordGateway() {
),
);
// Attach the immediate self-undeafen/self-unmute guard so the bot reacts
// INSTANTLY when an admin server-mutes or server-deafens it (previously
// only re-asserted on video-watch/reconnect, leaving the bot muted for
// minutes).
registerSelfVoiceStateGuard(client);
// Start retention cleanup scheduler
startRetentionCleanup();
// Start weekly moderation digest (public, automated)