added db test commands

This commit is contained in:
Soenke committed 2026-05-31 17:20:22 +02:00
1 parent d564756511
commit 4d34daa1e7
3 files changed
+38 -3

No files matched your search

+22 -2
View File
@@ -11,9 +11,9 @@ class DBTest(commands.Cog):
await interaction.response.defer(ephemeral=True)
try:
db_conn = self.bot.database.conn
db = self.bot.database.conn
async with db_conn.execute("SELECT 1;") as cursor:
async with db.execute("SELECT 1;") as cursor:
result = await cursor.fetchone()
if result:
@@ -25,5 +25,25 @@ class DBTest(commands.Cog):
except Exception as e:
await interaction.followup.send(f"Database connection failed: {e}")
@app_commands.command(name="test_db_add", description="Add a string to the Database")
@app_commands.describe(message="a message")
async def test_db(self, interaction: discord.Interaction, message: str):
await interaction.response.defer(ephemeral=True)
try:
db = self.bot.database.conn
await db.execute(
"INSERT INTO test (message) VALUES (?)",
(message,)
)
await db.commit()
await interaction.followup.send("Database INSERT was successful!")
except Exception as e:
await interaction.followup.send(f"Database INSERT failed: {e}")
async def setup(bot: commands.Bot):
await bot.add_cog(DBTest(bot))