improve disconnect logic a bit

This commit is contained in:
vveeps 2021-10-26 18:07:22 +03:00
parent 762160e84b
commit fd2d5645fe
1 changed files with 9 additions and 6 deletions

View File

@ -150,7 +150,7 @@ class Player(VoiceProtocol):
self._voice_state.update({"sessionId": data.get("session_id")})
if not (channel_id := data.get("channel_id")):
self.channel = None
await self.disconnect()
self._voice_state.clear()
return
@ -199,10 +199,13 @@ class Player(VoiceProtocol):
async def disconnect(self, *, force: bool = False):
await self.stop()
try:
await self.guild.change_voice_state(channel=None)
finally:
self._is_connected = False
self.cleanup()
self.channel = None
self._is_connected = False
del self._node._players[self.guild.id]
async def destroy(self):