diff options
| author | Rapptz <[email protected]> | 2017-04-18 04:09:33 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-04-18 04:09:33 -0400 |
| commit | d534a0989e1c1080d7361bb872545468174580ba (patch) | |
| tree | 67e40618de03cd429462cd51470515884b93daf7 | |
| parent | Add Guild.voice_client shortcut. (diff) | |
| download | discord.py-d534a0989e1c1080d7361bb872545468174580ba.tar.xz discord.py-d534a0989e1c1080d7361bb872545468174580ba.zip | |
Properly cleanup of VoiceClients in cache.
| -rw-r--r-- | discord/client.py | 4 | ||||
| -rw-r--r-- | discord/shard.py | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/discord/client.py b/discord/client.py index c8a81d33..fc03400b 100644 --- a/discord/client.py +++ b/discord/client.py @@ -429,15 +429,13 @@ class Client: self._closed.set() - for voice in list(self.voice_clients): + for voice in self.voice_clients: try: yield from voice.disconnect() except: # if an error happens during disconnects, disregard it. pass - self.connection._remove_voice_client(voice.guild.id) - if self.ws is not None and self.ws.open: yield from self.ws.close() diff --git a/discord/shard.py b/discord/shard.py index d3d54ab5..7937e375 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -240,6 +240,12 @@ class AutoShardedClient(Client): self._closed.set() + for vc in self.voice_clients: + try: + yield from vc.disconnect() + except: + pass + to_close = [shard.ws.close() for shard in self.shards.values()] yield from asyncio.wait(to_close, loop=self.loop) yield from self.http.close() |