Vicy_Publique/commandes/mes_ribs.py

45 lines
1.3 KiB
Python
Raw Permalink Normal View History

import discord
from discord import app_commands
from discord.ext import commands
from utils.bank_manager import BankManager
bank_manager = BankManager()
class MesRibs(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command(name="mes-ribs", description="Afficher tous vos RIBs")
async def mes_ribs(self, interaction: discord.Interaction):
comptes = await bank_manager.get_comptes_user(interaction.guild.id, interaction.user.id)
if not comptes:
await interaction.response.send_message(
"❌ Vous n'avez aucun compte bancaire.", ephemeral=True
)
return
embed = discord.Embed(
title=f"💳 RIBs de {interaction.user.display_name}",
color=discord.Color.blue(),
)
for c in comptes:
tva_text = f" | TVA: {c['tva_rate']}%" if c["account_type"] == "entreprise" else ""
embed.add_field(
name=f"{c['bank_name']} ({c['account_type']})",
value=(
f"**RIB :** `{c['rib']}`\n"
f"**Solde :** `{c['solde']:.2f}€`{tva_text}"
),
inline=False,
)
await interaction.response.send_message(embed=embed, ephemeral=True)
async def setup(bot):
await bot.add_cog(MesRibs(bot))