From 97996a1647b36738f6868f6061bf392010c42d2f Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Tue, 21 Feb 2023 19:35:09 -0300 Subject: [PATCH] Trying to fix error --- Music/VulkanInitializer.py | 3 ++- Parallelism/ThreadPlayer.py | 9 +++++++++ Parallelism/ThreadPlayerManager.py | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Music/VulkanInitializer.py b/Music/VulkanInitializer.py index c842cea..671b3e7 100644 --- a/Music/VulkanInitializer.py +++ b/Music/VulkanInitializer.py @@ -50,7 +50,8 @@ class VulkanInitializer: raise VulkanError(message='Failed to load some Cog') except VulkanError as e: - print(f'[Error Loading Vulkan] -> {e.message}') + print(f'[Error Loading Vulkan]') + print(e) def __getTotalCogs(self) -> int: quant = 0 diff --git a/Parallelism/ThreadPlayer.py b/Parallelism/ThreadPlayer.py index 3358f9b..94ecb21 100644 --- a/Parallelism/ThreadPlayer.py +++ b/Parallelism/ThreadPlayer.py @@ -334,6 +334,15 @@ class ThreadPlayer(Thread): async def __connectToVoiceChannel(self) -> bool: try: print('[CONNECTING TO VOICE CHANNEL]') + # If the voiceChannel is not defined yet, like if the Bot is still loading, wait until we get the voiceChannel + if self.__voiceChannel is None: + while True: + self.__voiceChannel = self.__bot.get_channel(self.__voiceChannelID) + if self.__voiceChannel is None: + await asyncio.sleep(0.2) + else: + break + if self.__voiceClient is not None: try: await self.__voiceClient.disconnect(force=True) diff --git a/Parallelism/ThreadPlayerManager.py b/Parallelism/ThreadPlayerManager.py index f90e145..a6c068a 100644 --- a/Parallelism/ThreadPlayerManager.py +++ b/Parallelism/ThreadPlayerManager.py @@ -116,7 +116,7 @@ class ThreadPlayerManager(Singleton, AbstractPlayersManager): else: voiceID: int = context.author.voice.channel.id - voiceChannel = self.__bot.get_channel(voiceID) + voiceChannel = context.author.voice.channel playlist = Playlist() lock = RLock() @@ -144,7 +144,7 @@ class ThreadPlayerManager(Singleton, AbstractPlayersManager): voiceID: int = context.user.voice.channel.id else: voiceID: int = context.author.voice.channel.id - voiceChannel = self.__bot.get_channel(voiceID) + voiceChannel = context.author.voice.channel playlist = self.__playersThreads[guildID].getPlaylist() lock = RLock()