Skip to content

More voice disconnect reasons #7582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/topics/opcodes-and-status-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ Our voice gateways have their own set of opcodes and close codes.
| 4009 | Session timeout | Your session has timed out. |
| 4011 | Server not found | We can't find the server you're trying to connect to. |
| 4012 | Unknown protocol | We didn't recognize the [protocol](/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload) you sent. |
| 4014 | Disconnected | Channel was deleted, you were kicked, voice server changed, or the main gateway session was dropped. Should not reconnect. |
| 4014 | Disconnected | Disconnect individual client (you were kicked, the main gateway session was dropped, etc.). Should not reconnect. |
| 4015 | Voice server crashed | The server crashed. Our bad! Try [resuming](/docs/topics/voice-connections#resuming-voice-connection). |
| 4016 | Unknown encryption mode | We didn't recognize your [encryption](/docs/topics/voice-connections#transport-encryption-and-sending-voice). |
| 4020 | Bad request | You sent a malformed request |
| 4021 | Disconnected | Disconnect due to rate limit exceeded. Should not reconnect. |
Copy link

@topi314 topi314 May 29, 2025

Choose a reason for hiding this comment

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

Disconnect due to rate limit exceeded

There are no mentions of rate limits in the voice docs.
Can we get more information on this?

| 4022 | Disconnected | Disconnect all clients (channel deleted, voice server changed, etc.). Should not reconnect. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this get sent when the user was the last connected one (see #7575)? Is that an oversight? Why does changing the voice server imply you shouldn't reconnect? That seems strange to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

The way we observe this close code implies 3 different scenarios (might be more idk what else is hidden behind "etc." here).

  1. Bot is kicked and channel is now empty -> no reconnect
  2. Channel is deleted -> no reconnect
  3. Voice server changed -> connect to new voice server (essentially reconnect with extra steps)

This means the client has to decide based on context information how to handle this closure. Which makes implementation unnecessarily difficult. I would expect all these scenarios to use different close codes.

  1. Should be 4014 as usual for voice kicks
  2. Can be 4022 (Channel deleted / User removed from guild / Channel no longer accessible / etc.)
  3. Should be a different code like 4023 (voice server changed), which can be handled differently.

Unless I'm completely misreading these docs, which means they can be improved.



## HTTP

Expand Down