mirror of
https://gitlab.jonasled.de/jonasled/discordbot
synced 2024-11-20 10:13:03 +01:00
added stop command for music bot
This commit is contained in:
parent
6967b44f0c
commit
3742d6ce44
1 changed files with 16 additions and 0 deletions
16
bot.py
16
bot.py
|
@ -432,6 +432,21 @@ async def que(ctx):
|
|||
|
||||
await ctx.message.channel.send(message)#send the prepared message
|
||||
|
||||
@bot.command(brief="stop the music bot and clear the que")
|
||||
async def stop(ctx):
|
||||
global player#import the global variables
|
||||
global playerQue
|
||||
global titleQue
|
||||
global downloadQue
|
||||
if (playerServer != ctx.message.guild.id):#check if the music bot runns on this server
|
||||
await ctx.message.channel.send("You can't stop the music bot on a different server.")
|
||||
return
|
||||
playerQue = []#delte all ques
|
||||
titleQue = []
|
||||
downloadQue = []
|
||||
player.stop()#stop the current song
|
||||
|
||||
|
||||
|
||||
async def checkForNextSong():#background task, that runns every seccond and checks if the song ended
|
||||
global player#import the global variables
|
||||
|
@ -451,6 +466,7 @@ async def checkForNextSong():#background task, that runns every seccond and chec
|
|||
await player.disconnect()
|
||||
player = None
|
||||
playerServer = None#allow everyone to invite the music bot
|
||||
remove("*.mp3")#delete all mp3 files
|
||||
else:
|
||||
playing = True#set playing to true and play the next file
|
||||
player.play(discord.FFmpegPCMAudio(playerQue[0]))
|
||||
|
|
Loading…
Reference in a new issue