general.py 文件源码

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

项目:spirit 作者: jgayfer 项目源码 文件源码
def about(self, ctx):
        """Display information about the bot itself

        This command was adapted from RoboDanny by Rapptz - https://www.github.com/Rapptz/RoboDanny
        """
        manager = MessageManager(self.bot, ctx.author, ctx.channel, ctx.prefix, [ctx.message])
        e = discord.Embed(title='Spirit v{}'.format(constants.VERSION), colour=constants.BLUE)

        e.description = ("[Invite Spirit](https://discordapp.com/oauth2/authorize?client_id=335084645743984641&scope=bot&permissions=523344)\n"
                           + "[Spirit Support Server](https://discord.gg/GXCFpkr)")

        owner = self.bot.get_user(118926942404608003)
        e.set_author(name=str(owner), icon_url=owner.avatar_url)

        # statistics
        total_members = sum(1 for _ in self.bot.get_all_members())
        total_online = len({m.id for m in self.bot.get_all_members() if m.status is discord.Status.online})
        total_unique = len(self.bot.users)

        voice_channels = []
        text_channels = []
        for guild in self.bot.guilds:
            voice_channels.extend(guild.voice_channels)
            text_channels.extend(guild.text_channels)

        text = len(text_channels)
        voice = len(voice_channels)

        e.add_field(name='Members', value='{} total\n{} unique\n{} unique online'.format(total_members, total_unique, total_online))
        e.add_field(name='Channels', value='{} total\n{} text\n{} voice'.format(text + voice, text, voice))

        memory_usage = "%0.2f" % (self.process.memory_full_info().uss / 1024**2)
        cpu_usage = "%0.2f" % (self.process.cpu_percent() / psutil.cpu_count())
        e.add_field(name='Process', value='{} MiB\n{}% CPU'.format(memory_usage, cpu_usage))

        e.add_field(name='Guilds', value=len(self.bot.guilds))
        e.add_field(name='Commands Run', value=self.bot.command_count)
        e.add_field(name='Uptime', value=self.get_bot_uptime(brief=True))

        e.set_footer(text='Made with discord.py', icon_url='http://i.imgur.com/5BFecvA.png')
        await manager.say(e, embed=True, delete=False)
        await manager.clear()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号