music.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Bonfire 作者: Phxntxm 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号