Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ These changes are available on the `master` branch, but have not yet been releas
([#2843](https://github.com/Pycord-Development/pycord/pull/2843))
- Fixed `TypeError` when using `@option` with certain annotations and along with
`channel_types`. ([#2835](https://github.com/Pycord-Development/pycord/pull/2835))
- Fixed reconnection issues with `VoiceClient` due to incorrectly trying to reconnect
with status code `4014`.
([#2870](https://github.com/Pycord-Development/pycord/pull/2870))

### Changed

Expand Down
17 changes: 4 additions & 13 deletions discord/voice_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,32 +465,23 @@ async def poll_voice_ws(self, reconnect: bool) -> None:
await self.ws.poll_event()
except (ConnectionClosed, asyncio.TimeoutError) as exc:
if isinstance(exc, ConnectionClosed):
# The following close codes are undocumented, so I will document them here.
# 1000 - normal closure (obviously)
# 4014 - voice channel has been deleted.
# 4015 - voice server has crashed, we should resume
if exc.code == 1000:
_log.info(
"Disconnecting from voice normally, close code %d.",
exc.code,
)
await self.disconnect()
break
# 4014 - Disconnect individual client (you were kicked, the main gateway session was dropped, etc.).
if exc.code == 4014:
_log.info(
"Disconnected from voice by force... potentially"
" reconnecting."
)
successful = await self.potential_reconnect()
if successful:
continue

_log.info(
"Reconnect was unsuccessful, disconnecting from voice"
" normally..."
"Disconnected from voice by force, close code %d.",
exc.code,
)
await self.disconnect()
break
# 4015 - The server crashed. Our bad! Try resuming.
if exc.code == 4015:
_log.info("Disconnected from voice, trying to resume...")

Expand Down
Loading