feat(aurora): add [p]aurora info command
All checks were successful
Actions / Build Documentation (MkDocs) (pull_request) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (pull_request) Successful in 50s

This commit is contained in:
Seaswimmer 2024-08-22 18:47:17 -04:00
parent fa8036291c
commit 6560f98aef
Signed by: cswimr
GPG key ID: 3813315477F26F82

View file

@ -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)