From 56d9272c12968c94587b103b3809d0e33ae1506f Mon Sep 17 00:00:00 2001 From: GZod01 Date: Wed, 18 Dec 2024 09:32:32 +0100 Subject: [PATCH] a --- perso_commands.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/perso_commands.py b/perso_commands.py index 76b1fce..392a7f4 100644 --- a/perso_commands.py +++ b/perso_commands.py @@ -104,9 +104,13 @@ class PersoCommands(app_commands.Group): @app_commands.command(name="lister",description="Liste les personnages sur le serveur") - @app_commands.describe(output_hidden="Afficher les personnages de manière cachée") - async def list_characters(self,interaction:discord.Interaction,output_hidden:bool=True): - res = await self.bot.db.execute("SELECT * FROM personnages WHERE guild_id=? OR guild_id IS NULL",(interaction.guild.id,)) + @app_commands.describe(universe_code="Le code de l'univers duquel afficher les personnages",output_hidden="Afficher les personnages de manière cachée") + async def list_characters(self,interaction:discord.Interaction,universe_code:str="",output_hidden:bool=True): + res=None + if universe_code!="": + res = await self.bot.db.execute("SELECT * FROM personnages WHERE (guild_id=? OR guild_id IS NULL) AND universe=?",(interaction.guild.id,universe_code)) + else: + res = await self.bot.db.execute("SELECT * FROM personnages WHERE guild_id=? OR guild_id IS NULL",(interaction.guild.id,)) rows = await res.fetchall() await res.close() embeds = [] @@ -115,13 +119,18 @@ class PersoCommands(app_commands.Group): await interaction.response.send_message("Liste des personnages",embeds=embeds,ephemeral=output_hidden) @app_commands.command(name="lister_tout",description="Liste tous les personnages") - async def list_all_characters(self,interaction:discord.Interaction,output_hidden:bool=True): + @app_commands.describe(universe_code="Le code de l'univers duquel afficher les personnages",output_hidden="Afficher les personnages de manière cachée") + async def list_all_characters(self,interaction:discord.Interaction,univers_code:str="",output_hidden:bool=True): #admin if interaction.user.id !=super_owner_id: await interaction.response.send_message("Vous n'avez pas la permission d'exécuter cette commande",ephemeral=True) return print("perso list") - res = await self.bot.db.execute("SELECT * FROM personnages") + res=None + if univers_code!="": + res = await self.bot.db.execute("SELECT * FROM personnages WHERE universe=?", (univers_code,)) + else: + res = await self.bot.db.execute("SELECT * FROM personnages") rows = await res.fetchall() await res.close() embeds = [] @@ -135,6 +144,10 @@ async def perso_embed(bot:GammaRPBot,perso_datas)->discord.embeds.Embed: embed.add_field(name="Pouvoirs",value=perso_datas["pouvoirs"]) embed.add_field(name="Age",value=perso_datas["age"]) embed.add_field(name="Sexe",value=perso_datas["sexe"]) + embed.add_field(name="Univers",value=perso_datas["universe"]) + embed.add_field(name="Argent",value=perso_datas["money"]) + embed.add_field(name="Utilisateur",value=f"<@{perso_datas['uuid']}>" if perso_datas['uuid'] is not None else "Global") + embed.add_field(name="Serveur",value=bot.get_guild(perso_datas['guild_id']).name if perso_datas['guild_id'] is not None else "Global") embed.set_footer(text=f"Nom court (ID): {perso_datas['nom_court']}") embed.set_thumbnail(url=perso_datas["image"]) return embed \ No newline at end of file