diff --git a/src/embed.py b/src/embed.py index e8bf18f..c3c1fa9 100644 --- a/src/embed.py +++ b/src/embed.py @@ -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 = "" diff --git a/src/musicbot.py b/src/musicbot.py index db13d4d..60aedf3 100644 --- a/src/musicbot.py +++ b/src/musicbot.py @@ -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) \ No newline at end of file