From 3eb79a073baf7fac46b3fceef593bddecea30ccc Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Sat, 6 Aug 2016 08:09:24 -0500 Subject: [PATCH] Added an ETA message to estimate the next song in the queue that's yours --- cogs/playlist.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cogs/playlist.py b/cogs/playlist.py index 13e684a..40b4639 100644 --- a/cogs/playlist.py +++ b/cogs/playlist.py @@ -217,6 +217,34 @@ class Music: await state.voice.disconnect() except: pass + @commands.command(pass_context=True, no_pm=True) + @checks.customPermsOrRole(send_messages=True) + async def eta(self, ctx): + """Provides an ETA on when your next song will play""" + state = self.get_voice_state(ctx.message.server) + author = ctx.message.author + + if not state.is_playing(): + await self.bot.say('Not playing any music right now...') + return + if len(state.songs._queue) == 0: + await self.bot.say("Nothing currently in the queue") + return + + count = state.current.duration + found = False + for song in state.songs._queue: + if song.requester == author: + found = True + break + count += song.player.duration + if count == state.current.duration: + await self.bot.say("You are next in the queue!") + return + if not found: + await self.bot.say("You are not in the queue!") + return + await self.bot.say("ETA till your next play is: {0[0]}m {0[1]}s]".format(divmod(round(count, 0), 60))) @commands.command(pass_context=True, no_pm=True) @checks.customPermsOrRole(send_messages=True)