fix(discord): voice inactivity timeout fires under /voice off, spamming the channel - #43328
Merged
Merged
Conversation
The voice inactivity timer (VOICE_TIMEOUT) only counted the bot's OWN audio playback as activity. Under /voice off (text-only replies, but still in the channel — leaving is /voice leave) nothing ever reset it, so every 300s the bot disconnected and spammed "Left voice channel (inactivity timeout)." The adapter now learns the live voice-reply mode via a getter wired from run.py and skips the auto-disconnect while mode is off. It also resets the timer when a user actually speaks to the bot, so an active listener (incl. voice-on text-only sessions that never play audio) isn't dropped mid-conversation.
Assert the inactivity handler skips disconnect (and the channel spam) when the voice-mode getter reports "off", and still disconnects on genuine inactivity when the mode is active.
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
gateway/run.py:9373: [invalid-assignment] invalid-assignment: Object of type `(chat_id) -> str` is not assignable to attribute `_voice_mode_getter` on type `BasePlatformAdapter & <Protocol with members 'join_voice_channel'> & <Protocol with members '_voice_mode_getter'>`
✅ Fixed issues: none
Unchanged: 5579 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
3 tasks
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
Discord bot no longer auto-disconnects and spams "Left voice channel (inactivity timeout)." every 300s while in
/voice offmode.Root cause: the inactivity timer (
VOICE_TIMEOUT) only resets on the bot's own audio playback./voice offis deliberate text-only mode that keeps the bot in the channel (leaving is/voice leave), so nothing ever resets the timer and it fires every 300s — disconnecting and spamming the text channel on a loop.Salvage of #43165 by @xxxigm (reported by PanBartosz), cherry-picked onto current main with authorship preserved.
Changes
plugins/platforms/discord/adapter.py:_voice_timeout_handlerskips the auto-disconnect when the linked channel's voice-reply mode isoff. Also resets the timer when a user speaks in_voice_listen_loop(sibling fix: an active listener was getting disconnected mid-conversation since only bot playback counted as activity).gateway/run.py: wires the gateway's live_voice_modestate into the adapter via a_voice_mode_gettercallback on voice-channel join.tests/gateway/test_voice_command.py: 2 new tests — timeout skips disconnect under/voice off, still disconnects under an active mode.Validation
/voice off, idle 5+ min/voice all/voice_only, idle 5+ mintests/gateway/test_voice_command.py: 183/183 passing. E2E-verified the real_voice_timeout_handlerskips disconnect under voice-off mode.Closes #43165.
Infographic