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)
This commit is contained in:
Dan 2024-06-19 07:59:32 -04:00
parent 7430769b06
commit 150c4a89f0
3 changed files with 13 additions and 5 deletions

BIN
bot.db

Binary file not shown.

View File

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

View File

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