From 6560f98aefe9315345b3ba15d1ce07ab8e97e432 Mon Sep 17 00:00:00 2001 From: cswimr Date: Thu, 22 Aug 2024 18:47:17 -0400 Subject: [PATCH] feat(aurora): add `[p]aurora info` command --- aurora/aurora.py | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 72b954b..46d88e0 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -45,8 +45,9 @@ class Aurora(commands.Cog): It is heavily inspired by GalacticBot, and is designed to be a more user-friendly alternative to Red's core Mod cogs. This cog stores all of its data in an SQLite database.""" - __author__ = ["cswimr"] - __version__ = "3.0.0-indev21" + __author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"] + __version__ = "3.0.0-indev22" + __git__ = "https://www.coastalcommits.com/cswimr/SeaCogs" __documentation__ = "https://seacogs.coastalcommits.com/aurora/" async def red_delete_data_for_user(self, *, requester, user_id: int): @@ -91,7 +92,7 @@ class Aurora(commands.Cog): n = "\n" if "\n\n" not in pre_processed else "" text = [ f"{pre_processed}{n}", - f"{bold('Cog Version:')} {self.__version__}", + f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})", f"{bold('Author:')} {humanize_list(self.__author__)}", f"{bold('Documentation:')} {self.__documentation__}", ] @@ -1333,3 +1334,44 @@ class Aurora(commands.Cog): await ctx.send(error("Please provide a convertible value!")) return await ctx.send(f"`{parsed_time}`") + + @aurora.command(name="info") + async def aurora_info(self, ctx: commands.Context): + """Get information about Aurora.""" + embed = discord.Embed( + title="Aurora Information", + color=await self.bot.get_embed_color(ctx.channel), + timestamp=datetime.now(), + ) + embed.set_thumbnail(url=self.bot.user.avatar.url) + embed.add_field( + name="Version", + value=f"[{self.__version__}](https://www.coastalcommits.com/cswimr/SeaCogs)" + ) + embed.add_field( + name="Author", + value=', '.join(self.__author__) + ) + if ctx.author.id in self.bot.owner_ids: + results = await Moderation.execute(query="SELECT name FROM sqlite_master WHERE type='table';", return_obj=False) + tables = [table[0] for table in results] + table_count = len(tables) + row_count = 0 + + for table in tables: + count_query = f"SELECT COUNT() FROM {table}" + result = await Moderation.execute(query=count_query, return_obj=False) + row_count += result[0][0] + + filesize = os.path.getsize(str(data_manager.cog_data_path(cog_instance=self) / "aurora.db")) / 1024 + + embed.add_field( + name="Database Stats", + value=f"{bold('Table Count:')} {table_count:,}\n{bold('Row Count:')} {row_count:,}\n{bold('File Size:')} {filesize:,.0f} KB", + ) + embed.add_field( + name="Moderation Types", + value=f"{len(type_registry)} registered types\n{box(', '.join(type_registry.keys()))}", + inline=False + ) + await ctx.send(embed=embed)