diff --git a/discord/gateway.py b/discord/gateway.py index 2ed93f9b3..a2c3da3d2 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -883,6 +883,7 @@ class DiscordVoiceWebSocket: *, resume: bool = False, hook: Optional[Callable[..., Coroutine[Any, Any, Any]]] = None, + seq_ack: int = -1, ) -> Self: """Creates a voice websocket for the :class:`VoiceClient`.""" gateway = f'wss://{state.endpoint}/?v=8' @@ -891,6 +892,7 @@ class DiscordVoiceWebSocket: socket = await http.ws_connect(gateway, compress=15) ws = cls(socket, loop=client.loop, hook=hook) ws.gateway = gateway + ws.seq_ack = seq_ack ws._connection = state ws._max_heartbeat_timeout = 60.0 ws.thread_id = threading.get_ident() diff --git a/discord/voice_state.py b/discord/voice_state.py index d0996acdb..33247cd10 100644 --- a/discord/voice_state.py +++ b/discord/voice_state.py @@ -574,7 +574,10 @@ class VoiceConnectionState: self._disconnected.clear() async def _connect_websocket(self, resume: bool) -> DiscordVoiceWebSocket: - ws = await DiscordVoiceWebSocket.from_connection_state(self, resume=resume, hook=self.hook) + seq_ack = -1 + if self.ws is not MISSING: + seq_ack = self.ws.seq_ack + ws = await DiscordVoiceWebSocket.from_connection_state(self, resume=resume, hook=self.hook, seq_ack=seq_ack) self.state = ConnectionFlowState.websocket_connected return ws