Misc.py 文件源码

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

项目:RPGBot 作者: henry232323 项目源码 文件源码
def info(self, ctx):
        """Bot Info"""
        me = self.bot.user if not ctx.guild else ctx.guild.me
        appinfo = await self.bot.application_info()
        embed = discord.Embed()
        embed.set_author(name=me.display_name, icon_url=appinfo.owner.avatar_url, url="https://github.com/henry232323/PokeRPG-Bot")
        embed.add_field(name="Author", value='Henry#6174 (Discord ID: 122739797646245899)')
        embed.add_field(name="Library", value='discord.py (Python)')
        embed.add_field(name="Uptime", value=await self.bot.get_bot_uptime())
        embed.add_field(name="Servers", value="{} servers".format(len(self.bot.guilds)))
        embed.add_field(name="Commands Run", value='{} commands'.format(sum(self.bot.commands_used.values())))

        total_members = sum(len(s.members) for s in self.bot.guilds)
        total_online = sum(1 for m in self.bot.get_all_members() if m.status != discord.Status.offline)
        unique_members = set(map(lambda x: x.id, self.bot.get_all_members()))
        channel_types = Counter(isinstance(c, discord.TextChannel) for c in self.bot.get_all_channels())
        voice = channel_types[False]
        text = channel_types[True]
        embed.add_field(name="Total Members", value='{} ({} online)'.format(total_members, total_online))
        embed.add_field(name="Unique Members", value='{}'.format(len(unique_members)))
        embed.add_field(name="Channels", value='{} text channels, {} voice channels'.format(text, voice))
        embed.add_field(name="Shards", value=f'Currently running {ctx.bot.shard_count} shards. This server is on shard {getattr(ctx.guild, "shard_id", 0)}')

        a = monotonic()
        await (await ctx.bot.shards[getattr(ctx.guild, "shard_id", 0)].ws.ping())
        b = monotonic()
        ping = "{:.3f}ms".format((b - a) * 1000)

        embed.add_field(name="CPU Percentage", value="{}%".format(psutil.cpu_percent()))
        embed.add_field(name="Memory Usage", value=self.bot.get_ram())
        embed.add_field(name="Observed Events", value=sum(self.bot.socket_stats.values()))
        embed.add_field(name="Ping", value=ping)

        embed.add_field(name="Source", value="[Github](https://github.com/henry232323/RPGBot)")

        embed.set_footer(text='Made with discord.py', icon_url='http://i.imgur.com/5BFecvA.png')
        embed.set_thumbnail(url=self.bot.user.avatar_url)
        await ctx.send(delete_after=60, embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号