Skip to content

Conversation

@vassjozsef
Copy link
Contributor

No description provided.

@vassjozsef vassjozsef requested a review from a team as a code owner May 28, 2025 20:41
@vassjozsef vassjozsef requested review from abe-discord and removed request for a team May 28, 2025 20:41
@advaith1
Copy link
Contributor

Can the "description" values be made unique? that field is used as the opcode name in enums

| 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. |
| 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.

| 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?

| 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: Rate Limited | Disconnect due to rate limit exceeded. Should not reconnect. |
| 4022 | Disconnected: Call Terminated | Disconnect all clients due to call terminatedc (channel deleted, voice server changed, etc.). Should not reconnect. |
Copy link

Choose a reason for hiding this comment

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

Suggested change
| 4022 | Disconnected: Call Terminated | Disconnect all clients due to call terminatedc (channel deleted, voice server changed, etc.). Should not reconnect. |
| 4022 | Disconnected: Call Terminated | Disconnect all clients due to call terminated (channel deleted, voice server changed, etc.). Should not reconnect. |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, fixed.

@vassjozsef
Copy link
Contributor Author

Can the "description" values be made unique? that field is used as the opcode name in enums

Done.

@colinloretz colinloretz self-requested a review June 5, 2025 22:42
| 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: Rate Limited | Disconnect due to rate limit exceeded. Should not reconnect. |
| 4022 | Disconnected: Call Terminated | Disconnect all clients due to call terminated (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.

Suggested change
| 4022 | Disconnected: Call Terminated | Disconnect all clients due to call terminated (channel deleted, voice server changed, etc.). Should not reconnect. |
| 4022 | Disconnected: Call Terminated | Disconnect all clients due to call termination (channel deleted, voice server changed, etc.). Should not reconnect. |

"terminated" is bad grammar here.

@vassjozsef vassjozsef merged commit ea32903 into main Jun 6, 2025
4 checks passed
@vassjozsef vassjozsef deleted the feature/more-voice-disconnect branch June 6, 2025 00:48
@ferrenza
Copy link

ferrenza commented Jun 6, 2025

Hey, I’d like to add a bit:
If there's no user in the voice channel except ourselves, and we move ourselves to another channel, the status code that appears will always be 4022.
But if the voice channel has at least 1 other user in it when we move ourselves, then it will first trigger a 4014, and when we return to the previous channel, the code that appears will be 4022.

Example: self move to other channels

🟢 (VC has at least 1 person)
Channel A → Channel B (4014)
Channel B → Channel A (4022)

🔴 (Nobody inside VC)
Channel A → Channel B (4022)
Channel B → Channel A (4022)
image

@vassjozsef
Copy link
Contributor Author

Hey, I’d like to add a bit: If there's no user in the voice channel except ourselves, and we move ourselves to another channel, the status code that appears will always be 4022. But if the voice channel has at least 1 other user in it when we move ourselves, then it will first trigger a 4014, and when we return to the previous channel, the code that appears will be 4022.

Example: self move to other channels

🟢 (VC has at least 1 person) Channel A → Channel B (4014) Channel B → Channel A (4022)

🔴 (Nobody inside VC) Channel A → Channel B (4022) Channel B → Channel A (4022) image

Yes you are correct. One reason for call terminated is last client leaving the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants