This commit is contained in:
GZod01 2024-12-17 11:21:15 +01:00
parent 02031d5a38
commit 05386d51e9

View file

@ -29,8 +29,8 @@ class MoneyCommands(app_commands.Group):
self.bot=bot self.bot=bot
@app_commands.command(name="donner",description="Donne de l'argent à un autre personnage") @app_commands.command(name="donner",description="Donne de l'argent à un autre personnage")
@app_commands.describe(amount="Le montant à donner",from_short_name="Le personnage depuis lequel prendre l'argent",to_short_name="Le personnage à qui donner l'argent") @app_commands.describe(amount="Le montant à donner",from_short_name="Le personnage depuis lequel prendre l'argent",to_short_name="Le personnage à qui donner l'argent",secret="Si l'opération doit être secrète")
async def give_money(self,interaction:discord.Interaction,amount:int,from_short_name:str,to_short_name:str): async def give_money(self,interaction:discord.Interaction,amount:int,from_short_name:str,to_short_name:str,secret=True):
if amount<=0: if amount<=0:
await interaction.response.send_message("Le montant doit être positif",ephemeral=True) await interaction.response.send_message("Le montant doit être positif",ephemeral=True)
return return
@ -50,16 +50,16 @@ class MoneyCommands(app_commands.Group):
await self.bot.db.execute("UPDATE personnages SET money=money-? WHERE nom_court=?", (amount,from_short_name)) await self.bot.db.execute("UPDATE personnages SET money=money-? WHERE nom_court=?", (amount,from_short_name))
await self.bot.db.execute("UPDATE personnages SET money=money+? WHERE nom_court=?", (amount,to_short_name)) await self.bot.db.execute("UPDATE personnages SET money=money+? WHERE nom_court=?", (amount,to_short_name))
await self.bot.db.commit() await self.bot.db.commit()
await interaction.response.send_message(f"Vous avez donné {amount} pièces à {to_short_name}",ephemeral=True) await interaction.response.send_message(f"{from_short_name} vient de donner {amount} pièces à {to_short_name}",ephemeral=not secret)
@app_commands.command(name="voir",description="Voir votre solde ou le solde d'un autre personnage") @app_commands.command(name="voir",description="Voir votre solde ou le solde d'un autre personnage")
@app_commands.describe(short_name="Le personnage dont vous voulez voir le solde") @app_commands.describe(short_name="Le personnage dont vous voulez voir le solde",secret="Si l'opération doit être secrète")
async def see_money(self,interaction:discord.Interaction,short_name:str): async def see_money(self,interaction:discord.Interaction,short_name:str,secret=True):
check_exist = await self.bot.db.execute("SELECT money FROM personnages WHERE nom_court=?", (short_name,)) check_exist = await self.bot.db.execute("SELECT money FROM personnages WHERE nom_court=?", (short_name,))
money = await check_exist.fetchone() money = await check_exist.fetchone()
if money is None: if money is None:
await interaction.response.send_message("Ce personnage n'existe pas",ephemeral=True) await interaction.response.send_message("Ce personnage n'existe pas",ephemeral=True)
return return
await interaction.response.send_message(f"{short_name} a {money['money']} pièces",ephemeral=True) await interaction.response.send_message(f"{short_name} a {money['money']} pièces",ephemeral=not secret)
@app_commands.command(name="admin_ajouter",description="Ajoute de l'argent à un personnage") @app_commands.command(name="admin_ajouter",description="Ajoute de l'argent à un personnage")
@app_commands.describe(amount="Le montant à ajouter",short_name="Le personnage à qui ajouter l'argent") @app_commands.describe(amount="Le montant à ajouter",short_name="Le personnage à qui ajouter l'argent")