Fixing errors when closing the player info and trying to access it again

This commit is contained in:
Rafael Vargas
2023-03-14 00:25:33 -03:00
parent db405285ac
commit 8f18ef3f2e
13 changed files with 28 additions and 27 deletions

View File

@@ -342,11 +342,13 @@ class ThreadPlayer(Thread):
else:
break
if self.__voiceClient is not None:
try:
await self.__voiceClient.disconnect(force=True)
except Exception as e:
print(f'[THREAD PLAYER -> ERROR FORCING DISCONNECT] -> {e}')
try:
voiceClient = self.__guild.voice_client
if voiceClient is not None:
await voiceClient.disconnect(force=True)
except Exception as e:
print(f'[THREAD PLAYER -> ERROR FORCING DISCONNECT] -> {e}')
self.__voiceClient = await self.__voiceChannel.connect(reconnect=True, timeout=None)
return True
except Exception as e: