improve disconnect logic a bit
This commit is contained in:
parent
762160e84b
commit
fd2d5645fe
|
|
@ -150,7 +150,7 @@ class Player(VoiceProtocol):
|
||||||
self._voice_state.update({"sessionId": data.get("session_id")})
|
self._voice_state.update({"sessionId": data.get("session_id")})
|
||||||
|
|
||||||
if not (channel_id := data.get("channel_id")):
|
if not (channel_id := data.get("channel_id")):
|
||||||
self.channel = None
|
await self.disconnect()
|
||||||
self._voice_state.clear()
|
self._voice_state.clear()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -199,10 +199,13 @@ class Player(VoiceProtocol):
|
||||||
|
|
||||||
async def disconnect(self, *, force: bool = False):
|
async def disconnect(self, *, force: bool = False):
|
||||||
await self.stop()
|
await self.stop()
|
||||||
|
|
||||||
|
try:
|
||||||
await self.guild.change_voice_state(channel=None)
|
await self.guild.change_voice_state(channel=None)
|
||||||
|
finally:
|
||||||
|
self._is_connected = False
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
self.channel = None
|
self.channel = None
|
||||||
self._is_connected = False
|
|
||||||
del self._node._players[self.guild.id]
|
del self._node._players[self.guild.id]
|
||||||
|
|
||||||
async def destroy(self):
|
async def destroy(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue