From ad05fffa84591b6055410082aea9c56c160fce09 Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Thu, 30 Dec 2021 20:37:09 -0400 Subject: [PATCH] Music will now wait for the first preload of first song --- vulkanbot/music/Music.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/vulkanbot/music/Music.py b/vulkanbot/music/Music.py index 41368cb..2ad2a18 100644 --- a/vulkanbot/music/Music.py +++ b/vulkanbot/music/Music.py @@ -95,11 +95,27 @@ class Music(commands.Cog): await self.__send_embed(ctx, description=f"Você adicionou {songs_quant} músicas à fila!", colour_name='blue') if not self.__playing: - first = self.__playlist.songs_to_preload[0] - self.__downloader.download_one(first) - first_song = self.__playlist.next_song() + try_another = True + + while try_another: + first = self.__playlist.next_song() + if first == None: + await self.__send_embed(ctx, description='Houve um problema no download dessa música, tente novamente', colour_name='blue') + break + + while True: + if first.source != None: # If song got downloaded + try_another = False + break - await self.__play_music(ctx, first_song) + if first.problematic: # If song got any error, try another one + break + + else: # The song is downloading, checking another time + continue + + if first != None: + await self.__play_music(ctx, first) @commands.command(name="queue", help="Mostra as atuais músicas da fila.", aliases=['q', 'fila']) async def queue(self, ctx):