a
This commit is contained in:
parent
7e57ff0000
commit
4f0ef731bc
1 changed files with 20 additions and 5 deletions
|
@ -29,9 +29,13 @@ class PersoCommands(app_commands.Group):
|
|||
@app_commands.command(name="créer",description="Crée un personnage")
|
||||
@app_commands.describe(short_name="Le nom court du personnage (son ID)", full_name="Le nom complet du personnage",
|
||||
story="L'histoire du personnage",powers="Les pouvoirs du personnage",age="L'âge du personnage",
|
||||
sexe="Le sexe du personnage",guild_only="Personnage global ou uniquement sur ce serveur",image="L'image du personnage")
|
||||
@app_commands.choices(guild_only=[app_commands.Choice(name="Global",value="global"),app_commands.Choice(name="Ce serveur uniquement", value="guild")])
|
||||
async def create_character(self,interaction:discord.Interaction,short_name:str,full_name:str,image:discord.Attachment,story:str,powers:str,age:int,sexe:str,guild_only:app_commands.Choice[str]):
|
||||
sexe="Le sexe du personnage",
|
||||
# guild_only="Personnage global ou uniquement sur ce serveur",
|
||||
image="L'image du personnage")
|
||||
# @app_commands.choices(guild_only=[app_commands.Choice(name="Global",value="global"),app_commands.Choice(name="Ce serveur uniquement", value="guild")])
|
||||
async def create_character(self,interaction:discord.Interaction,short_name:str,full_name:str,image:discord.Attachment,story:str,powers:str,age:int,sexe:str,
|
||||
# guild_only:app_commands.Choice[str]
|
||||
):
|
||||
nom_court = short_name
|
||||
nom_complet= full_name
|
||||
if image.content_type!="image/png" and image.content_type!="image/jpeg":
|
||||
|
@ -50,7 +54,7 @@ class PersoCommands(app_commands.Group):
|
|||
print(image.url)
|
||||
print(image_blob)
|
||||
try:
|
||||
res = await self.bot.db.execute("INSERT INTO personnages (nom_court,nom_complet,histoire,pouvoirs,age,sexe,uuid,guild_id,image) VALUES (?,?,?,?,?,?,?,?,?)",(nom_court,nom_complet,histoire,pouvoirs,age,sexe,uuid,guild_id,image_blob))
|
||||
res = await self.bot.db.execute("INSERT INTO personnages (nom_court,nom_complet,histoire,pouvoirs,age,sexe,uuid,image) VALUES (?,?,?,?,?,?,?,?,?)",(nom_court,nom_complet,histoire,pouvoirs,age,sexe,uuid,image_blob))
|
||||
print(res)
|
||||
await res.close()
|
||||
await self.bot.db.commit()
|
||||
|
@ -67,6 +71,17 @@ class PersoCommands(app_commands.Group):
|
|||
await interaction.response.send_message("Erreur lors de la création du personnage",ephemeral=True)
|
||||
return
|
||||
await interaction.response.send_message("Personnage créé",ephemeral=True)
|
||||
@app_commands.command(name="afficher",description="Affiche un personnage")
|
||||
@app_commands.describe(short_name="Le nom court du personnage")
|
||||
async def show_character(self,interaction:discord.Interaction,short_name:str):
|
||||
res = await self.bot.db.execute("SELECT * FROM personnages WHERE nom_court=? AND uuid=? AND (guild_id=? OR guild_id IS NULL)",(short_name,interaction.user.id,interaction.guild.id))
|
||||
row = await res.fetchone()
|
||||
await res.close()
|
||||
if row is None:
|
||||
await interaction.response.send_message("Personnage non trouvé",ephemeral=True)
|
||||
return
|
||||
embed = await perso_embed(self.bot,row)
|
||||
await interaction.response.send_message("Personnage trouvé",embed=embed,ephemeral=True)
|
||||
@app_commands.command(name="lister",description="Liste tous les personnages")
|
||||
async def list_characters(self,interaction:discord.Interaction):
|
||||
print("perso list")
|
||||
|
@ -92,5 +107,5 @@ async def perso_embed(bot:GammaRPBot,perso_datas)->discord.embeds.Embed:
|
|||
embed.add_field(name="Age",value=perso_datas["age"])
|
||||
embed.add_field(name="Sexe",value=perso_datas["sexe"])
|
||||
embed.set_footer(text=f"Nom court (ID): {perso_datas['nom_court']}")
|
||||
embed.set_image(url=perso_image_url)
|
||||
embed.set_thumbnail(url=perso_image_url)
|
||||
return embed
|
Loading…
Reference in a new issue