From 150c4a89f0eb4b14d2b095acb6e5e7e6a311fd5d Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 19 Jun 2024 07:59:32 -0400 Subject: [PATCH] FEAT: Added Help command (can't test yet due to Discord's Sync time) REF: Changed the database name to reflect the bot's name (ariella instead of bot) --- bot.db | Bin 8192 -> 0 bytes commands.py | 16 ++++++++++++---- main.py | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) delete mode 100644 bot.db diff --git a/bot.db b/bot.db deleted file mode 100644 index b5477bb8a6ef6f07caee34a2e667490805c17754..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8192 zcmeI#PYZ%D7zXf7f*^>xb$z`RR1kfEEJjooWrOk*Mhm2Wpz8zFCvOTO<)L%&JUHgN zcRKjpwqCiRR&=~Ymq1gW)fwk(K*Sj1W>{uqN$OHom^rDxg|qHvS~a_P&1L36AOHaf zKmY;|fB*y_009U<00KWR@aXY!!?yXeql5if-D4H)t~agX{LLD9!jXccGjs*z>(s2! zN780^pvgjtvG8c=P3Dg0(@gm7!shfCl42{1y;w)#NyXWZ-o9-mcXM;;M<4(J2tWV= T5P$##AOHafKmY;|_+x<=Au}}* diff --git a/commands.py b/commands.py index 7316896..de12b97 100644 --- a/commands.py +++ b/commands.py @@ -14,7 +14,7 @@ class ModCommands(commands.Cog): @app_commands.command(name="addnote", description="Add a note to a user") async def add_note(self, interaction: discord.Interaction, user: discord.User, note: str): - async with aiosqlite.connect("bot.db") as db: + async with aiosqlite.connect("ariella.db") as db: cursor = await db.execute( "SELECT notes FROM user_notes WHERE user_id = ?", (user.id,) @@ -40,7 +40,7 @@ class ModCommands(commands.Cog): @app_commands.command(name="warn", description="Warn a user") async def warn_user(self, interaction: discord.Interaction, user: discord.User, reason: str): - async with aiosqlite.connect("bot.db") as db: + async with aiosqlite.connect("ariella.db") as db: cursor = await db.execute( "SELECT strikes FROM user_notes WHERE user_id = ?", (user.id,) @@ -73,7 +73,7 @@ class ModCommands(commands.Cog): description="Check notes and strikes of a user") async def check_notes(self, interaction: discord.Interaction, user: discord.User): - async with aiosqlite.connect("bot.db") as db: + async with aiosqlite.connect("ariella.db") as db: cursor = await db.execute( "SELECT notes, strikes FROM user_notes WHERE user_id = ?", (user.id,) @@ -90,7 +90,7 @@ class ModCommands(commands.Cog): ) @app_commands.command(name="update", - description="Update the bot from the repository") + description="Update Ariellia to the latest version") @commands.is_owner() async def update(self, interaction: discord.Interaction): await interaction.response.send_message("Updating the bot...") @@ -100,6 +100,14 @@ class ModCommands(commands.Cog): await interaction.followup.send("Restarting the bot...") os.execv(sys.executable, ['python'] + sys.argv) + @app_commands.command(name="help", description="List all commands") + async def help_command(self, interaction: discord.Interaction): + commands = self.bot.tree.walk_commands() + help_text = "Here are the available commands:\n" + for command in commands: + help_text += f"/{command.name} - {command.description}\n" + await interaction.response.send_message(help_text) + async def setup(bot): await bot.add_cog(ModCommands(bot)) diff --git a/main.py b/main.py index 90e1ce8..e917b0a 100644 --- a/main.py +++ b/main.py @@ -30,7 +30,7 @@ bot = Ariella() # Database setup async def init_db(): - async with aiosqlite.connect("bot.db") as db: + async with aiosqlite.connect("ariella.db") as db: await db.execute(""" CREATE TABLE IF NOT EXISTS user_notes ( user_id INTEGER PRIMARY KEY,