shortened status message,

add queue peek comand,
add pause and resume command
This commit is contained in:
Arthur Lu 2022-09-17 18:18:22 +00:00
parent 08f14235e9
commit d7fb919fff
2 changed files with 67 additions and 0 deletions

View File

@ -2,6 +2,17 @@ import discord
from pytube import YouTube
def get_status(channel, queue, playing):
desc = 'playing {0} in {1}'.format(playing.title, channel)
emb = discord.Embed(title='music-bot', description=desc,color=0x0000FF)
if(queue.has_next()):
lst = "next up: {0}".format(queue.elem[0].title)
else:
lst = "empty queue"
emb.add_field(name="{0} tracks left in queue".format(queue.num_remaining()), value=lst)
emb.set_thumbnail(url=playing.thumbnail_url)
return emb
def get_queue(channel, queue, playing):
desc = 'playing {0} in {1}'.format(playing.title, channel)
emb = discord.Embed(title='music-bot', description=desc,color=0x0000FF)
lst = ""

View File

@ -227,4 +227,60 @@ async def search(ctx, *args):
bot.previous_search = s.results
await ctx.send(embed=get_search_results(query, s.results))
@bot.command()
async def peek(ctx, *args):
roleid = bot.config['guild']['roleid']
prefix = bot.config['guild']['prefix']
if(len(args) != 0):
await ctx.send(embed=get_error("usage: {0}peek".format(prefix)))
return
elif(ctx.author.voice == None):
await ctx.send(embed=get_error("you are not in a voice channel"))
return
elif(roleid not in [role.id for role in ctx.author.roles]):
await ctx.send(embed=get_error("you do not have the role to play music"))
return
await ctx.send(embed=get_queue(ctx.voice_client.channel, bot.queue, bot.currently_playing))
@bot.command()
async def pause(ctx, *args):
roleid = bot.config['guild']['roleid']
prefix = bot.config['guild']['prefix']
if(len(args) != 0):
await ctx.send(embed=get_error("usage: {0}pause".format(prefix)))
return
elif(ctx.author.voice == None):
await ctx.send(embed=get_error("you are not in a voice channel"))
return
elif(roleid not in [role.id for role in ctx.author.roles]):
await ctx.send(embed=get_error("you do not have the role to play music"))
return
ctx.voice_client.pause()
await ctx.send(embed=get_success("paused"))
@bot.command()
async def resume(ctx, *args):
roleid = bot.config['guild']['roleid']
prefix = bot.config['guild']['prefix']
if(len(args) != 0):
await ctx.send(embed=get_error("usage: {0}resume".format(prefix)))
return
elif(ctx.author.voice == None):
await ctx.send(embed=get_error("you are not in a voice channel"))
return
elif(roleid not in [role.id for role in ctx.author.roles]):
await ctx.send(embed=get_error("you do not have the role to play music"))
return
ctx.voice_client.resume()
await ctx.send(embed=get_success("resumed"))
bot.run(token)