import discord async def execute(bot, params, message): channels = params.get('channels', []) if not channels: # Fallback for single channel channels = [params] guild = message.guild created_count = 0 for channel_params in channels: channel_name = channel_params.get('channel_name') if not channel_name: await message.channel.send("Nom de salon requis pour la création.") continue category_name = channel_params.get('category_name') channel_type = (channel_params.get('channel_type') or 'textuel').casefold() category = None if category_name: # Recherche flexible : trouver une catégorie dont le nom contient le terme recherché category = discord.utils.find( lambda cat: category_name.casefold() in cat.name.casefold(), guild.categories ) if not category: # Create the category if it doesn't exist try: category = await guild.create_category(category_name) await message.channel.send(f"Catégorie '{category_name}' créée.") except discord.Forbidden: await message.channel.send(f"Je n'ai pas les permissions pour créer la catégorie '{category_name}'.") continue try: if channel_type == 'textuel': channel = await guild.create_text_channel(channel_name, category=category) elif channel_type == 'vocal': channel = await guild.create_voice_channel(channel_name, category=category) else: await message.channel.send(f"Type de salon invalide pour '{channel_name}'. Utilisez 'textuel' ou 'vocal'.") continue created_count += 1 except discord.Forbidden: await message.channel.send(f"Je n'ai pas les permissions pour créer le salon '{channel_name}'.") if created_count > 0: await message.channel.send(f"{created_count} salon(s) créé(s).")