def progress(self, ctx):
"""Provides the progress of the current song"""
# Make sure we're playing first
state = self.get_voice_state(ctx.message.server)
if not state.is_playing():
await self.bot.say('Not playing anything.')
else:
progress = state.current.progress
length = state.current.length
# Another check, just to make sure; this may happen for a very brief amount of time
# Between when the song was requested, and still downloading to play
if not progress or not length:
await self.bot.say('Not playing anything.')
return
# Otherwise just format this nicely
progress = divmod(round(progress, 0), 60)
length = divmod(round(length, 0), 60)
fmt = "Current song progress: {0[0]}m {0[1]}s/{1[0]}m {1[1]}s".format(progress, length)
await self.bot.say(fmt)
评论列表
文章目录