From 7c286a4f82532382b0a9e5a5ffd8b3a166fabf75 Mon Sep 17 00:00:00 2001 From: wlinator Date: Sun, 1 Sep 2024 08:14:43 -0400 Subject: [PATCH] feat: Update admin commands --- modules/admin/admin.py | 34 ++++++++++++++++++++++++++++++++-- modules/admin/award.py | 19 ++++++++++++++++++- modules/admin/blacklist.py | 11 +++++++++++ modules/admin/dev.py | 25 +++++++++++++++++++++++-- 4 files changed, 84 insertions(+), 5 deletions(-) diff --git a/modules/admin/admin.py b/modules/admin/admin.py index 4d87cdf..87b1f34 100644 --- a/modules/admin/admin.py +++ b/modules/admin/admin.py @@ -13,7 +13,22 @@ class Sql(commands.Cog): @commands.command(name="sqlselect", aliases=["sqls"]) @commands.is_owner() - async def select_cmd(self, ctx: commands.Context[commands.Bot], *, query: str) -> None: + async def select_cmd( + self, + ctx: commands.Context[commands.Bot], + *, + query: str, + ) -> None: + """ + Execute a SQL SELECT query. + + Parameters + ---------- + ctx : commands.Context[commands.Bot] + The context of the command. + query : str + The SQL query to execute. + """ if query.lower().startswith("select "): query = query[7:] @@ -45,7 +60,22 @@ class Sql(commands.Cog): @commands.command(name="sqlinject", aliases=["sqli"]) @commands.is_owner() - async def inject_cmd(self, ctx: commands.Context[commands.Bot], *, query: str) -> None: + async def inject_cmd( + self, + ctx: commands.Context[commands.Bot], + *, + query: str, + ) -> None: + """ + Execute a SQL INJECT query. + + Parameters + ---------- + ctx : commands.Context[commands.Bot] + The context of the command. + query : str + The SQL query to execute. + """ try: database.execute_query(query) embed = Builder.create_embed( diff --git a/modules/admin/award.py b/modules/admin/award.py index 7a38afe..f7165db 100644 --- a/modules/admin/award.py +++ b/modules/admin/award.py @@ -12,7 +12,24 @@ class Award(commands.Cog): @commands.command(name="award") @commands.is_owner() - async def award_command(self, ctx: commands.Context[commands.Bot], user: discord.User, amount: int) -> None: + async def award_command( + self, + ctx: commands.Context[commands.Bot], + user: discord.User, + amount: int, + ) -> None: + """ + Award a user with a specified amount of currency. + + Parameters + ---------- + ctx : commands.Context[commands.Bot] + The context of the command. + user : discord.User + The user to award. + amount : int + The amount of currency to award. + """ curr = Currency(user.id) curr.add_balance(amount) curr.push() diff --git a/modules/admin/blacklist.py b/modules/admin/blacklist.py index ce2c01c..fed6479 100644 --- a/modules/admin/blacklist.py +++ b/modules/admin/blacklist.py @@ -19,6 +19,17 @@ class Blacklist(commands.Cog): *, reason: str | None = None, ) -> None: + """ + Blacklist a user from the bot. + + Parameters + ---------- + ctx : commands.Context[commands.Bot] + The context of the command. + user : discord.User + The user to blacklist. + reason : str | None, optional + """ blacklist_service = BlacklistUserService(user.id) blacklist_service.add_to_blacklist(reason) diff --git a/modules/admin/dev.py b/modules/admin/dev.py index 86a2fb6..a546e04 100644 --- a/modules/admin/dev.py +++ b/modules/admin/dev.py @@ -17,13 +17,22 @@ class Dev(commands.Cog): @dev.command( name="sync_tree", aliases=["sync"], - usage="sync_tree [guild]", ) async def sync( self, ctx: commands.Context[commands.Bot], guild: discord.Guild | None = None, ) -> None: + """ + Sync the bot's tree to the specified guild. + + Parameters + ---------- + ctx : commands.Context[commands.Bot] + The context of the command. + guild : discord.Guild | None, optional + The guild to sync the tree to, by default None. + """ if guild: self.bot.tree.copy_global_to(guild=guild) @@ -31,12 +40,24 @@ class Dev(commands.Cog): await ctx.send(content=CONST.STRINGS["dev_sync_tree"]) - @dev.command(name="clear_tree", aliases=["clear"]) + @dev.command( + name="clear_tree", + aliases=["clear"], + ) async def sync_global( self, ctx: commands.Context[commands.Bot], guild: discord.Guild | None = None, ) -> None: + """ + Clear the bot's tree for the specified guild. + + Parameters + ---------- + ctx : commands.Context[commands.Bot] + The context of the command. + guild : discord.Guild | None, optional + """ self.bot.tree.clear_commands(guild=guild) await ctx.send(content=CONST.STRINGS["dev_clear_tree"])