aboutsummaryrefslogtreecommitdiff
path: root/code/cogs
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-06-26 14:59:25 -0500
committerParker <contact@pkrm.dev>2024-06-26 14:59:25 -0500
commite418e06ce6feaade6adffe4041576e0b1596523d (patch)
tree652269d9d4fb639cddd3e0239867c74b4dfc6e18 /code/cogs
parent9a31885078c70de1bc0838dd97ee0d25d3adbac2 (diff)
Consolidate info + stats commands
Diffstat (limited to 'code/cogs')
-rw-r--r--code/cogs/owner/info.py45
-rw-r--r--code/cogs/owner/stats.py22
2 files changed, 15 insertions, 52 deletions
diff --git a/code/cogs/owner/info.py b/code/cogs/owner/info.py
deleted file mode 100644
index e596e91..0000000
--- a/code/cogs/owner/info.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from discord.ext import commands
-import discord
-
-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.playing_players}`\nLoad: `{round(self.bot.lavalink.nodes[0].stats.lavalink_load * 100, 2)}%`",
- 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/owner/stats.py b/code/cogs/owner/stats.py
index 3ca31a2..d81ec13 100644
--- a/code/cogs/owner/stats.py
+++ b/code/cogs/owner/stats.py
@@ -56,16 +56,24 @@ class Stats(commands.Cog):
connection = sqlite3.connect("count.db")
cursor = connection.cursor()
- embed = discord.Embed(title="Command Statistics", color=BOT_COLOR)
+ # Pull the top 5 commands being run
+ data = cursor.execute(
+ "SELECT * FROM count ORDER BY count DESC LIMIT 5"
+ ).fetchall()
+
+ # Get the combined total amount of commands run
+ total_commands = cursor.execute("SELECT SUM(count) FROM count").fetchone()[0]
+
+ embed = discord.Embed(
+ title="Statistics",
+ description=f"Total Guilds: `{len(self.bot.guilds):,}`\nTotal Commands: `{total_commands:,}`\n\nTotal Players: `{self.bot.lavalink.nodes[0].stats.playing_players}`\nLoad: `{round(self.bot.lavalink.nodes[0].stats.lavalink_load * 100, 2)}%`",
+ color=BOT_COLOR,
+ )
- total = 0
- data = cursor.execute("SELECT * FROM count").fetchall()
for entry in data:
- embed.add_field(name=entry[0], value=f"` {entry[1]} `", inline=True)
- total += entry[1]
-
- embed.add_field(name="TOTAL", value=f"` {total} `", inline=False)
+ embed.add_field(name=entry[0], value=f"` {entry[1]:,} `", inline=True)
+ connection.close()
await ctx.send(embed=embed)