diff --git a/discord/gateway.py b/discord/gateway.py index 928e37be8..4d2c9cca3 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -199,6 +199,8 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol): ws._dispatch = client.dispatch ws.gateway = gateway + client.connection._update_references(ws) + log.info('Created websocket connected to {}'.format(gateway)) if not resume: yield from ws.identify() diff --git a/discord/state.py b/discord/state.py index 634a2749b..268af1885 100644 --- a/discord/state.py +++ b/discord/state.py @@ -107,6 +107,10 @@ class ConnectionState: def _remove_voice_client(self, guild_id): self._voice_clients.pop(guild_id, None) + def _update_references(self, ws): + for vc in self.voice_clients: + vc.main_ws = ws + @property def servers(self): return self._servers.values()