Ajout de la création de la table 'personnages' et amélioration de l'affichage des informations des personnages

This commit is contained in:
GZod01 2024-12-15 15:24:49 +01:00
parent df0ebbb4ad
commit 04c4353a6b

View file

@ -5,6 +5,18 @@ import aiosqlite
import base64 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): async def setup(bot:GammaRPBot):
bot.tree.add_command(PersoCommands(bot)) bot.tree.add_command(PersoCommands(bot))
class PersoCommands(app_commands.Group): class PersoCommands(app_commands.Group):
@ -57,12 +69,11 @@ class PersoCommands(app_commands.Group):
async def list_characters(self,interaction:discord.Interaction): async def list_characters(self,interaction:discord.Interaction):
print("perso list") print("perso list")
res = await self.bot.db.execute("SELECT * FROM personnages") res = await self.bot.db.execute("SELECT * FROM personnages")
dict_rows = await res.fetchall() rows = await res.fetchall()
await res.close() await res.close()
print(dict_rows)
message="" message=""
for row in dict_rows: for row in rows:
print(row) 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) await interaction.response.send_message("Liste des personnages\n"+message,ephemeral=True)