From 04c4353a6b203330a7939e153d234adef0937e3a Mon Sep 17 00:00:00 2001 From: GZod01 Date: Sun, 15 Dec 2024 15:24:49 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20cr=C3=A9ation=20de=20la=20tab?= =?UTF-8?q?le=20'personnages'=20et=20am=C3=A9lioration=20de=20l'affichage?= =?UTF-8?q?=20des=20informations=20des=20personnages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- perso_commands.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/perso_commands.py b/perso_commands.py index e00c969..530c2af 100644 --- a/perso_commands.py +++ b/perso_commands.py @@ -5,6 +5,18 @@ import aiosqlite import base64 +_sql_table="""CREATE TABLE personnages ( + nom_court varchar(255), + nom_complet text, + image blob, + histoire text, + pouvoirs text, + uuid TEXT, + age INTEGER, + sexe TEXT, + guild_id INTEGER NULL +)""" + async def setup(bot:GammaRPBot): bot.tree.add_command(PersoCommands(bot)) class PersoCommands(app_commands.Group): @@ -57,12 +69,11 @@ class PersoCommands(app_commands.Group): async def list_characters(self,interaction:discord.Interaction): print("perso list") res = await self.bot.db.execute("SELECT * FROM personnages") - dict_rows = await res.fetchall() + rows = await res.fetchall() await res.close() - print(dict_rows) message="" - for row in dict_rows: + for row in rows: print(row) - message+=(f"Nom court: {row[0]}\nNom complet: {row[1]}\nHistoire: {row[2]}\nPouvoirs: {row[3]}\nAge: {row[4]}\nSexe: {row[5]}\nUUID: {row[6]}\nGuild ID: {row[7]}"+"\n\n") + message+=f"Nom court: {row[0]}\nNom complet: {row[1]}\nHistoire: {row[3]}\nPouvoirs: {row[4]}\nAge: {row[6]}\nSexe: {row[7]}\n\n" await interaction.response.send_message("Liste des personnages\n"+message,ephemeral=True) \ No newline at end of file