From 17212074b13884abbd9e57a193ee3942d6423061 Mon Sep 17 00:00:00 2001 From: Jonas Leder Date: Fri, 10 Apr 2020 16:54:44 +0200 Subject: [PATCH] fixed some errors in musicbot --- bot.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bot.py b/bot.py index b840912..6e9ad70 100644 --- a/bot.py +++ b/bot.py @@ -408,13 +408,13 @@ async def play(ctx, songURL : str): await ctx.message.channel.send("Can't find the song") return await ctx.message.channel.send("Adding `" + loads(r.text)["title"] + "` to que.") - downloadQue.append(songURL) + downloadQue.append([loads(r.text)["html"].split("src=")[1][1:].split("\"")[0], loads(r.text)["title"]]) @bot.command(brief="skipps the current song in playlist") async def skip(ctx): global player player.stop() - ctx.message.channel.send("Skipped to next song") + await ctx.message.channel.send("Skipped to next song") async def checkForNextSong(): @@ -426,20 +426,19 @@ async def checkForNextSong(): while True: if(player != None) and not player.is_playing() and (len(playerQue) > 0): if(playing): - remove(playerQue[0]) playerQue.remove(playerQue[0]) + titleQue.remove(titleQue[0]) playing = False if(len(playerQue) == 0): print("que is empty") - player.disconnect() + await player.disconnect() player = None playerServer = None else: playing = True print("playing next song") player.play(discord.FFmpegPCMAudio(playerQue[0])) - else: - await asyncio.sleep(1) + await asyncio.sleep(1) async def downloadAudioFiles(): global downloadQue @@ -456,12 +455,12 @@ async def downloadAudioFiles(): 'outtmpl': str(fileIndex) +'.%(ext)s', } with YoutubeDL(ydl_opts) as ydl: - ydl.download([downloadQue[0]]) - downloadQue.remove(downloadQue[0]) + ydl.download([downloadQue[0][0]]) playerQue.append(str(fileIndex) + ".mp3") + titleQue.append(downloadQue[0][1]) + downloadQue.remove(downloadQue[0]) fileIndex = fileIndex + 1 - else: - await asyncio.sleep(1) + await asyncio.sleep(1) bot.loop.create_task(checkForNextSong())