mirror of
https://gitlab.jonasled.de/jonasled/discordbot
synced 2024-10-03 07:48:58 +02:00
fixed some errors in musicbot
This commit is contained in:
parent
d03a76c7a5
commit
17212074b1
1 changed files with 9 additions and 10 deletions
19
bot.py
19
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())
|
||||
|
|
Loading…
Reference in a new issue