from __future__ import annotations import logging import discord from discord import app_commands from discord.ext import commands from features import shared logger = logging.getLogger("vision") class Shop(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot @app_commands.command(name="shop_setup", description="Configurer les annonces boutique") @app_commands.describe(channel="Canal des annonces boutique") @app_commands.checks.has_permissions(manage_guild=True) async def shop_setup(self, interaction: discord.Interaction, channel: discord.TextChannel): shared.set(interaction.guild_id, "shop", {"channel_id": channel.id, "enabled": True}) await interaction.response.send_message(f"Annonces boutique dans {channel.mention}", ephemeral=True) @app_commands.command(name="shop_announce", description="Annoncer un nouveau produit") @app_commands.describe(name="Nom du produit", description="Description", price="Prix", image_url="URL de l'image") @app_commands.checks.has_permissions(manage_guild=True) async def shop_announce( self, interaction: discord.Interaction, name: str, description: str, price: str = "", image_url: str = "", ): cfg = shared.section(interaction.guild_id, "shop") if not cfg.get("enabled"): await interaction.response.send_message("Boutique non configurée.", ephemeral=True) return channel = interaction.guild.get_channel(cfg["channel_id"]) if not channel: await interaction.response.send_message("Canal boutique introuvable.", ephemeral=True) return embed = discord.Embed( title=f"🆕 Nouveau produit — {name}", description=description, color=0x2F3136, ) if price: embed.add_field(name="💰 Prix", value=price, inline=True) if image_url: embed.set_image(url=image_url) embed.set_footer(text=f"Annoncé par {interaction.user}") await channel.send(embed=embed) await interaction.response.send_message(f"Annonce envoyée dans {channel.mention}", ephemeral=True) async def setup(bot: commands.Bot): await bot.add_cog(Shop(bot))