async def do_infodump(self): print("do_infodump() entered") if not settings.infodump_path: return # nothing to do here guilds_count = len(self.bot.guilds) member_count = botdata.count_users_with_key("steam") data = {"servers": guilds_count, "registered_users": member_count} try: with open(settings.infodump_path, "w+") as f: f.write(json.dumps(data)) except Exception as e: await self.send_owner(f"do_infodump failed w/ exception: {e}")
async def botstats(self, ctx): """Displays some bot statistics""" await ctx.channel.trigger_typing() 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( botdata.count_users_with_key("steam"))) thisweek = "timestamp between datetime('now', '-7 days') AND datetime('now', 'localtime')" query_results = await loggingdb.query_multiple([ f"select count(*) from messages where command is not null", f"select count(*) from messages where command is not null and {thisweek}", f"select command from messages where command is not null group by command order by count(command) desc limit 3", f"select command from messages where command is not null and {thisweek} group by command order by count(command) desc limit 3" ]) # embed.add_field(name="Commands", value=f"{query_results[0][0][0]:,}") embed.add_field(name="Commands (This Week)", value=f"{query_results[1][0][0]:,}") cmdpfx = self.cmdpfx(ctx) top_commands = query_results[2] # if len(top_commands) >= 3: # embed.add_field(name="Top Commands", value=( # f"`{cmdpfx}{top_commands[0][0]}`\n" # f"`{cmdpfx}{top_commands[1][0]}`\n" # f"`{cmdpfx}{top_commands[2][0]}`\n")) top_commands_weekly = query_results[3] if len(top_commands_weekly) >= 3: embed.add_field(name="Top Commands (This Week)", value=(f"`{cmdpfx}{top_commands_weekly[0][0]}`\n" f"`{cmdpfx}{top_commands_weekly[1][0]}`\n" f"`{cmdpfx}{top_commands_weekly[2][0]}`\n")) await ctx.send(embed=embed)