aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-05-22 00:58:27 -0400
committerRapptz <[email protected]>2016-05-22 00:58:27 -0400
commit8f4816ddaef9950e7d8f7ee650788042b9fbc3c8 (patch)
tree18bcedca7438612b45360f3b8be1434557bdf0d5
parentFix purge_from to use LogsFromIterator.create (#219) (diff)
downloaddiscord.py-8f4816ddaef9950e7d8f7ee650788042b9fbc3c8.tar.xz
discord.py-8f4816ddaef9950e7d8f7ee650788042b9fbc3c8.zip
Close voice connections before closing the websocket.
-rw-r--r--discord/client.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/discord/client.py b/discord/client.py
index a39f8227..bdbab67b 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -418,12 +418,18 @@ class Client:
if self.is_closed:
return
+ for voice in list(self.voice_clients):
+ try:
+ yield from voice.disconnect()
+ except:
+ # if an error happens during disconnects, disregard it.
+ pass
+
+ self.connection._remove_voice_client(voice.server.id)
+
if self.ws is not None and self.ws.open:
yield from self.ws.close()
- for voice in list(self.voice_clients):
- yield from voice.disconnect()
- self.connection._remove_voice_client(voice.server.id)
yield from self.session.close()
self._closed.set()