From 831fad53f16476068bb9f842a1d469bb674c4b1c Mon Sep 17 00:00:00 2001 From: Parker Date: Wed, 3 Apr 2024 15:42:03 -0500 Subject: Move `user_count.py` to `info.py` in `owner` folder --- code/cogs/owner/info.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ code/cogs/user_count.py | 45 --------------------------------------------- 2 files changed, 46 insertions(+), 45 deletions(-) create mode 100644 code/cogs/owner/info.py delete mode 100644 code/cogs/user_count.py (limited to 'code/cogs') diff --git a/code/cogs/owner/info.py b/code/cogs/owner/info.py new file mode 100644 index 0000000..dfa4844 --- /dev/null +++ b/code/cogs/owner/info.py @@ -0,0 +1,46 @@ +from discord.ext import commands +import discord +import lavalink + +from global_variables import BOT_COLOR + + +class Info(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command() + @commands.dm_only() + @commands.is_owner() + async def info(self, ctx: commands.Context): + total_guilds = {} + + for guild in self.bot.guilds: + total_guilds[guild.name] = guild.member_count + + # Sort the dictionary by value descending + total_guilds = dict( + sorted(total_guilds.items(), key=lambda item: item[1], reverse=True) + ) + + total_members = 0 + + for guild in total_guilds: + total_members += total_guilds[guild] + + embed = discord.Embed( + title="User Count", + description=f"Total Members: `{total_members:,}`\nTotal Guilds: `{len(self.bot.guilds):,}`\n\nTotal Players: `{self.bot.lavalink.nodes[0].stats.players}`", + color=BOT_COLOR, + ) + # Add the top 5 guilds to the embed + for guild in list(total_guilds)[:5]: + embed.add_field( + name=guild, value=f"```{total_guilds[guild]:,}```", inline=False + ) + + await ctx.send(embed=embed) + + +async def setup(bot): + await bot.add_cog(Info(bot)) diff --git a/code/cogs/user_count.py b/code/cogs/user_count.py deleted file mode 100644 index c2d7321..0000000 --- a/code/cogs/user_count.py +++ /dev/null @@ -1,45 +0,0 @@ -from discord.ext import commands -import discord - -from global_variables import BOT_COLOR - - -class UserCount(commands.Cog): - def __init__(self, bot): - self.bot = bot - - @commands.command() - @commands.dm_only() - @commands.is_owner() - async def info(self, ctx: commands.Context): - total_guilds = {} - - for guild in self.bot.guilds: - total_guilds[guild.name] = guild.member_count - - # Sort the dictionary by value descending - total_guilds = dict( - sorted(total_guilds.items(), key=lambda item: item[1], reverse=True) - ) - - total_members = 0 - - for guild in total_guilds: - total_members += total_guilds[guild] - - embed = discord.Embed( - title="User Count", - description=f"Total Members: `{total_members:,}`\nTotal Guilds: `{len(self.bot.guilds):,}`", - color=BOT_COLOR, - ) - # Add the top 5 guilds to the embed - for guild in list(total_guilds)[:5]: - embed.add_field( - name=guild, value=f"```{total_guilds[guild]:,}```", inline=False - ) - - await ctx.send(embed=embed) - - -async def setup(bot): - await bot.add_cog(UserCount(bot)) -- cgit v1.2.3-70-g09d2