Compare commits
No commits in common. "69eb415361dd4d99a0ac37dcad137add5955f3b2" and "e51e0f475eb288fa0ea4bec700e61a789e114721" have entirely different histories.
69eb415361
...
e51e0f475e
1 changed files with 6 additions and 19 deletions
|
@ -31,10 +31,11 @@ class PersoCommands(app_commands.Group):
|
||||||
@app_commands.describe(short_name="Le nom court du personnage (son ID)", full_name="Le nom complet du 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",
|
story="L'histoire du personnage",powers="Les pouvoirs du personnage",age="L'âge du personnage",
|
||||||
sexe="Le sexe du personnage",
|
sexe="Le sexe du personnage",
|
||||||
global_character="Le personnage est il global ou reservé à ce serveur",
|
# guild_only="Personnage global ou uniquement sur ce serveur",
|
||||||
image="L'image du personnage")
|
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,
|
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,
|
||||||
global_character:bool=False
|
# guild_only:app_commands.Choice[str]
|
||||||
):
|
):
|
||||||
nom_court = short_name
|
nom_court = short_name
|
||||||
nom_complet= full_name
|
nom_complet= full_name
|
||||||
|
@ -59,11 +60,7 @@ class PersoCommands(app_commands.Group):
|
||||||
print(image.filename)
|
print(image.filename)
|
||||||
print(image.url)
|
print(image.url)
|
||||||
try:
|
try:
|
||||||
res
|
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,perso_image_url))
|
||||||
if global_character:
|
|
||||||
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,perso_image_url))
|
|
||||||
else:
|
|
||||||
res=await self.bot.db.execute("INSERT INTO personnages (nom_court,nom_complet,histoire,pouvoirs,age,sexe,uuid,image,guild_id) VALUES (?,?,?,?,?,?,?,?)",(nom_court,nom_complet,histoire,pouvoirs,age,sexe,uuid,perso_image_url,guild_id))
|
|
||||||
print(res)
|
print(res)
|
||||||
await res.close()
|
await res.close()
|
||||||
await self.bot.db.commit()
|
await self.bot.db.commit()
|
||||||
|
@ -97,18 +94,8 @@ class PersoCommands(app_commands.Group):
|
||||||
rows = await res.fetchall()
|
rows = await res.fetchall()
|
||||||
await res.close()
|
await res.close()
|
||||||
return [app_commands.OptionChoice(name=row["nom_court"],value=row["nom_court"]) for row in rows]
|
return [app_commands.OptionChoice(name=row["nom_court"],value=row["nom_court"]) for row in rows]
|
||||||
@app_commands.command(name="lister",description="Liste les personnages sur le serveur")
|
@app_commands.command(name="lister",description="Liste tous les personnages")
|
||||||
async def list_characters(self,interaction:discord.Interaction,output_hidden:bool=True):
|
async def list_characters(self,interaction:discord.Interaction,output_hidden:bool=False):
|
||||||
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 = []
|
|
||||||
for row in rows:
|
|
||||||
embeds.append(await perso_embed(self.bot,row))
|
|
||||||
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_characters(self,interaction:discord.Interaction,output_hidden:bool=True):
|
|
||||||
#admin
|
#admin
|
||||||
if interaction.user.id !=super_owner_id:
|
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)
|
await interaction.response.send_message("Vous n'avez pas la permission d'exécuter cette commande",ephemeral=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue