general.py 文件源码

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

项目:MangoByte 作者: mdiller 项目源码 文件源码
def botstats(self, ctx):
        """Displays some bot statistics"""
        embed = discord.Embed(color=discord.Color.green())

        embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar_url)

        embed.add_field(name="Servers/Guilds", value="{:,}".format(len(self.bot.guilds)))
        embed.add_field(name="Registered Users", value="{:,}".format(len(list(filter(lambda user: user.steam32, botdata.userinfo_list())))))

        commands = loggingdb_session.query(loggingdb.Message).filter(loggingdb.Message.command != None)
        commands_weekly = commands.filter(loggingdb.Message.timestamp > datetime.datetime.utcnow() - datetime.timedelta(weeks=1))
        embed.add_field(name="Commands", value=f"{commands.count():,}")
        embed.add_field(name="Commands (This Week)", value=f"{commands_weekly.count():,}")


        top_commands = loggingdb_session.query(loggingdb.Message.command, func.count(loggingdb.Message.command)).filter(loggingdb.Message.command != None).group_by(loggingdb.Message.command).order_by(func.count(loggingdb.Message.command).desc())
        if top_commands.count() >= 3:
            embed.add_field(name="Top Commands", value=(
                f"`?{top_commands[0][0]}`\n"
                f"`?{top_commands[1][0]}`\n"
                f"`?{top_commands[2][0]}`\n"))

        top_commands_weekly = top_commands.filter(loggingdb.Message.timestamp > datetime.datetime.utcnow() - datetime.timedelta(weeks=1))
        if top_commands_weekly.count() >= 3:
            embed.add_field(name="Top Commands (This Week)", value=(
                f"`?{top_commands_weekly[0][0]}`\n"
                f"`?{top_commands_weekly[1][0]}`\n"
                f"`?{top_commands_weekly[2][0]}`\n"))

        await ctx.send(embed=embed)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号