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:
parent
7430769b06
commit
150c4a89f0
16
commands.py
16
commands.py
@ -14,7 +14,7 @@ class ModCommands(commands.Cog):
|
|||||||
@app_commands.command(name="addnote", description="Add a note to a user")
|
@app_commands.command(name="addnote", description="Add a note to a user")
|
||||||
async def add_note(self, interaction: discord.Interaction,
|
async def add_note(self, interaction: discord.Interaction,
|
||||||
user: discord.User, note: str):
|
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(
|
cursor = await db.execute(
|
||||||
"SELECT notes FROM user_notes WHERE user_id = ?",
|
"SELECT notes FROM user_notes WHERE user_id = ?",
|
||||||
(user.id,)
|
(user.id,)
|
||||||
@ -40,7 +40,7 @@ class ModCommands(commands.Cog):
|
|||||||
@app_commands.command(name="warn", description="Warn a user")
|
@app_commands.command(name="warn", description="Warn a user")
|
||||||
async def warn_user(self, interaction: discord.Interaction,
|
async def warn_user(self, interaction: discord.Interaction,
|
||||||
user: discord.User, reason: str):
|
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(
|
cursor = await db.execute(
|
||||||
"SELECT strikes FROM user_notes WHERE user_id = ?",
|
"SELECT strikes FROM user_notes WHERE user_id = ?",
|
||||||
(user.id,)
|
(user.id,)
|
||||||
@ -73,7 +73,7 @@ class ModCommands(commands.Cog):
|
|||||||
description="Check notes and strikes of a user")
|
description="Check notes and strikes of a user")
|
||||||
async def check_notes(self, interaction: discord.Interaction,
|
async def check_notes(self, interaction: discord.Interaction,
|
||||||
user: discord.User):
|
user: discord.User):
|
||||||
async with aiosqlite.connect("bot.db") as db:
|
async with aiosqlite.connect("ariella.db") as db:
|
||||||
cursor = await db.execute(
|
cursor = await db.execute(
|
||||||
"SELECT notes, strikes FROM user_notes WHERE user_id = ?",
|
"SELECT notes, strikes FROM user_notes WHERE user_id = ?",
|
||||||
(user.id,)
|
(user.id,)
|
||||||
@ -90,7 +90,7 @@ class ModCommands(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@app_commands.command(name="update",
|
@app_commands.command(name="update",
|
||||||
description="Update the bot from the repository")
|
description="Update Ariellia to the latest version")
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def update(self, interaction: discord.Interaction):
|
async def update(self, interaction: discord.Interaction):
|
||||||
await interaction.response.send_message("Updating the bot...")
|
await interaction.response.send_message("Updating the bot...")
|
||||||
@ -100,6 +100,14 @@ class ModCommands(commands.Cog):
|
|||||||
await interaction.followup.send("Restarting the bot...")
|
await interaction.followup.send("Restarting the bot...")
|
||||||
os.execv(sys.executable, ['python'] + sys.argv)
|
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):
|
async def setup(bot):
|
||||||
await bot.add_cog(ModCommands(bot))
|
await bot.add_cog(ModCommands(bot))
|
||||||
|
2
main.py
2
main.py
@ -30,7 +30,7 @@ bot = Ariella()
|
|||||||
|
|
||||||
# Database setup
|
# Database setup
|
||||||
async def init_db():
|
async def init_db():
|
||||||
async with aiosqlite.connect("bot.db") as db:
|
async with aiosqlite.connect("ariella.db") as db:
|
||||||
await db.execute("""
|
await db.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS user_notes (
|
CREATE TABLE IF NOT EXISTS user_notes (
|
||||||
user_id INTEGER PRIMARY KEY,
|
user_id INTEGER PRIMARY KEY,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user