from discord import app_commands import discord from GammaRPBot_Define import GammaRPBot import aiosqlite import base64 import io from public_env import * _sql_table="""CREATE TABLE personnages ( nom_court varchar(255), nom_complet text, image text, histoire text, pouvoirs text, uuid TEXT, age INTEGER, sexe TEXT, money INTEGER DEFAULT 50, guild_id INTEGER NULL )""" async def setup(bot:GammaRPBot): bot.tree.add_command(MoneyCommands(bot)) class MoneyCommands(app_commands.Group): bot:GammaRPBot def __init__(self,bot): super().__init__(name="argent",description="Commandes pour l'argent") self.bot=bot @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") async def give_money(self,interaction:discord.Interaction,amount:int,from_short_name:str,to_short_name:str): if amount<=0: await interaction.response.send_message("Le montant doit être positif",ephemeral=True) return check_exist = await self.bot.db.execute("SELECT money FROM personnages WHERE nom_court=? AND uuid=?", (from_short_name,interaction.user.id)) money = await check_exist.fetchone() if money is None: await interaction.response.send_message("Ce personnage n'existe pas ou ne vous appartient pas",ephemeral=True) return if money['money']