"""Command definitions for Superviseur bot.""" import discord from discord.ext import commands class ChannelCommands(commands.Cog): """Commands for channel management.""" def __init__(self, bot): self.bot = bot @commands.command(name="create_channel") async def cmd_create_channel(self, ctx, *args): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(args) == 0: await ctx.send("Usage: !create_channel name1 [name2 ...] [category_name type]") return if len(args) >= 3 and args[-2].lower() in ['textuel', 'vocal', 'text', 'voice']: channels = args[:-2] category = args[-2] type_ = args[-1] elif len(args) >= 2 and args[-1].lower() in ['textuel', 'vocal', 'text', 'voice']: channels = args[:-1] category = None type_ = args[-1].lower() if type_ == 'text': type_ = 'textuel' elif type_ == 'voice': type_ = 'vocal' else: channels = args category = None type_ = 'textuel' params = {'channels': [{'channel_name': name, 'category_name': category, 'channel_type': type_} for name in channels]} from commandes.salons.creer import execute await execute(self.bot, params, ctx.message) @commands.command(name="delete_channel") async def cmd_delete_channel(self, ctx, *channels): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(channels) == 0: await ctx.send("Usage: !delete_channel channel1 [channel2 ...]") return params = {'channels': [{'channel_name': name} for name in channels]} from commandes.salons.supprimer import execute await execute(self.bot, params, ctx.message) @commands.command(name="move_channel") async def cmd_move_channel(self, ctx, *args): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(args) % 2 != 0: await ctx.send("Usage: !move_channel channel1 new_category [channel2 new_category ...]") return params = {'channels': [{'channel_name': args[i], 'new_category_name': args[i+1]} for i in range(0, len(args), 2)]} from commandes.salons.deplacer import execute await execute(self.bot, params, ctx.message) @commands.command(name="modify_channel") async def cmd_modify_channel(self, ctx, channel_name, new_name=None, new_category=None, topic=None, user_limit=None): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return params = {'channels': [{'channel_name': channel_name, 'new_name': new_name, 'new_category_name': new_category, 'topic': topic, 'user_limit': int(user_limit) if user_limit else None}]} from commandes.salons.modifier import execute await execute(self.bot, params, ctx.message) @commands.command(name="rename_channel") async def cmd_rename_channel(self, ctx, *args): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(args) % 2 != 0: await ctx.send("Usage: !rename_channel channel1 new_name [channel2 new_name ...]") return params = {'channels': [{'channel_name': args[i], 'new_name': args[i+1]} for i in range(0, len(args), 2)]} from commandes.salons.renommer import execute await execute(self.bot, params, ctx.message) class CategoryCommands(commands.Cog): """Commands for category management.""" def __init__(self, bot): self.bot = bot @commands.command(name="create_category") async def cmd_create_category(self, ctx, *categories): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(categories) == 0: await ctx.send("Usage: !create_category name1 [name2 ...]") return params = {'categories': [{'category_name': name} for name in categories]} from commandes.categories.creer import execute await execute(self.bot, params, ctx.message) @commands.command(name="delete_category") async def cmd_delete_category(self, ctx, *categories): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(categories) == 0: await ctx.send("Usage: !delete_category name1 [name2 ...]") return params = {'categories': [{'category_name': name} for name in categories]} from commandes.categories.supprimer import execute await execute(self.bot, params, ctx.message) @commands.command(name="modify_category") async def cmd_modify_category(self, ctx, category_name, new_name=None): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if new_name is None: await ctx.send("Usage: !modify_category category_name new_name") return params = {'categories': [{'category_name': category_name, 'new_name': new_name}]} from commandes.categories.modifier import execute await execute(self.bot, params, ctx.message) @commands.command(name="rename_category") async def cmd_rename_category(self, ctx, *args): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(args) % 2 != 0: await ctx.send("Usage: !rename_category category1 new_name [category2 new_name ...]") return params = {'categories': [{'category_name': args[i], 'new_name': args[i+1]} for i in range(0, len(args), 2)]} from commandes.categories.renommer import execute await execute(self.bot, params, ctx.message) @commands.command(name="move_category") async def cmd_move_category(self, ctx, *args): if not ctx.author.guild_permissions.manage_channels: await ctx.send("Vous n'avez pas les permissions nécessaires.") return if len(args) % 2 != 0: await ctx.send("Usage: !move_category category1 position [category2 position ...]") return try: params = {'categories': [{'category_name': args[i], 'position': int(args[i+1])} for i in range(0, len(args), 2)]} except ValueError: await ctx.send("La position doit être un nombre entier.") return from commandes.categories.deplacer import execute await execute(self.bot, params, ctx.message) class SecurityCommands(commands.Cog): """Commands for security/moderation.""" def __init__(self, bot): self.bot = bot @commands.command(name="kick") async def cmd_kick(self, ctx, *users_mentions_or_ids): if not ctx.author.guild_permissions.kick_members: await ctx.send("Vous n'avez pas les permissions nécessaires pour expulser des membres.") return if len(users_mentions_or_ids) == 0: await ctx.send("Usage: !kick @user1 @user2 ...") return params = {'users': [{'target_user_mention': user} for user in users_mentions_or_ids]} from commandes.security.kick import execute await execute(self.bot, params, ctx.message) @commands.command(name="ban") async def cmd_ban(self, ctx, *users_mentions_or_ids): if not ctx.author.guild_permissions.ban_members: await ctx.send("Vous n'avez pas les permissions nécessaires pour bannir des membres.") return if len(users_mentions_or_ids) == 0: await ctx.send("Usage: !ban @user1 @user2 ...") return params = {'users': [{'target_user_mention': user} for user in users_mentions_or_ids]} from commandes.security.ban import execute await execute(self.bot, params, ctx.message) @commands.command(name="unban") async def cmd_unban(self, ctx, *users_mentions_or_ids): if not ctx.author.guild_permissions.ban_members: await ctx.send("Vous n'avez pas les permissions nécessaires pour débannir des membres.") return if len(users_mentions_or_ids) == 0: await ctx.send("Usage: !unban user_id1 user_id2 ...") return params = {'users': [{'target_user_mention': user} for user in users_mentions_or_ids]} from commandes.security.unban import execute await execute(self.bot, params, ctx.message) @commands.command(name="mute") async def cmd_mute(self, ctx, user_mention_or_id, duration_minutes: int, reason=None): if not ctx.author.guild_permissions.moderate_members: await ctx.send("Vous n'avez pas les permissions nécessaires pour muter des membres.") return params = {'users': [{'target_user_mention': user_mention_or_id, 'duration': duration_minutes, 'reason': reason or "Aucune raison spécifiée"}]} from commandes.security.mute import execute await execute(self.bot, params, ctx.message) @commands.command(name="timeout") async def cmd_timeout(self, ctx, user_mention_or_id, duration_minutes: int, reason=None): if not ctx.author.guild_permissions.moderate_members: await ctx.send("Vous n'avez pas les permissions nécessaires pour appliquer un timeout.") return params = {'users': [{'target_user_mention': user_mention_or_id, 'duration': duration_minutes, 'reason': reason or "Aucune raison spécifiée"}]} from commandes.security.timeout import execute await execute(self.bot, params, ctx.message) @commands.command(name="purge") async def cmd_purge(self, ctx, amount: int, channel_name=None): if not ctx.author.guild_permissions.manage_messages: await ctx.send("Vous n'avez pas les permissions nécessaires pour purger des messages.") return params = {'purges': [{'amount': amount, 'channel_name': channel_name or ctx.channel.name}]} from commandes.security.purge import execute await execute(self.bot, params, ctx.message) @commands.command(name="warn") async def cmd_warn(self, ctx, user_mention_or_id, *, reason): if not ctx.author.guild_permissions.moderate_members: await ctx.send("Vous n'avez pas les permissions nécessaires pour avertir des membres.") return params = {'warnings': [{'target_user_mention': user_mention_or_id, 'reason': reason}]} from commandes.security.warn import execute await execute(self.bot, params, ctx.message) @commands.command(name="list_warnings") async def cmd_list_warnings(self, ctx, user_mention_or_id=None): if not ctx.author.guild_permissions.moderate_members: await ctx.send("Vous n'avez pas les permissions nécessaires pour lister les avertissements.") return params = {'target_user_mention': user_mention_or_id} from commandes.mod.list_warnings import execute await execute(self.bot, params, ctx.message) class OtherCommands(commands.Cog): """Miscellaneous commands.""" def __init__(self, bot): self.bot = bot @commands.command(name="set_welcome_channel") async def cmd_set_welcome_channel(self, ctx, channel_name): if not ctx.author.guild_permissions.manage_guild: await ctx.send("Vous n'avez pas les permissions nécessaires pour définir le salon de bienvenue.") return params = {'channel_name': channel_name} from commandes.autres.setwelcomechannel import execute await execute(self.bot, params, ctx.message) @commands.command(name="set_goodbye_channel") async def cmd_set_goodbye_channel(self, ctx, channel_name): if not ctx.author.guild_permissions.manage_guild: await ctx.send("Vous n'avez pas les permissions nécessaires pour définir le salon d'au revoir.") return params = {'channel_name': channel_name} from commandes.autres.setgoodbyechannel import execute await execute(self.bot, params, ctx.message) @commands.command(name="set_mute_role") async def cmd_set_mute_role(self, ctx, role_name): if not ctx.author.guild_permissions.manage_roles: await ctx.send("Vous n'avez pas les permissions nécessaires pour définir le rôle mute.") return params = {'role_name': role_name} from commandes.autres.setmuterole import execute await execute(self.bot, params, ctx.message) @commands.command(name="send_message") async def cmd_send_message(self, ctx, channel_name=None, dm_user=None, *, message_content): if not ctx.author.guild_permissions.manage_messages: await ctx.send("Vous n'avez pas les permissions nécessaires pour envoyer des messages via cette commande.") return if not channel_name and not dm_user: await ctx.send("Usage: !send_message [channel_name] [dm_user] message_content") return params = {'channel_name': channel_name, 'dm_user': dm_user, 'message': message_content} from commandes.autres.send_message import execute await execute(self.bot, params, ctx.message) class BêtaExpansionCommands(commands.Cog): """Expanded Bêta commands for Social Index and Voice.""" def __init__(self, bot): self.bot = bot @commands.command(name="voice_diag") async def cmd_voice_diag(self, ctx): """Diagnose tactical voice connectivity issues.""" if not (ctx.author.id in self.bot.admin_ids or self.bot.has_whitelist_permission(ctx.author.id, 'wl')): return guild = ctx.guild me = guild.me report = ["**◈ VOICE DIAGNOSTICS ◈**"] # Check current state active_vc = guild.voice_client report.append(f"- Active Voice Client: `{'CONNECTED' if active_vc else 'IDLE'}`") report.append(f"- Ear Protocol (Library): `{'READY' if self.bot.voice_manager.HAS_VOICE_RECV else 'MISSING'}`") report.append(f"- Monitoring Status: `{'ACTIVE' if self.bot.voice_manager.is_monitoring else 'INACTIVE'}`") if active_vc: report.append(f"- Current Channel: `{active_vc.channel.name}`") # Check permissions for all channels report.append("\n**◈ CANAL PERMISSIONS ◈**") for channel in guild.voice_channels: perms = channel.permissions_for(me) status = "✅" if (perms.connect and perms.view_channel) else "❌" reason = [] if not perms.view_channel: reason.append("CANNOT VIEW") if not perms.connect: reason.append("CANNOT CONNECT") report.append(f"- `{channel.name}`: {status} {'(' + ', '.join(reason) + ')' if reason else ''}") # Check Admin identity match user_match = "MATCHED" if ctx.author.id in self.bot.admin_ids else "NOMINAL" report.append(f"\n- Admin IDs (Config): `{self.bot.admin_ids}`") report.append(f"- Your ID: `{ctx.author.id}` ({user_match})") await self.bot.messaging.send_embed( ctx.author, "REPORT: TACTICAL CONNECTIVITY", "\n".join(report), color=discord.Color.blue(), is_asset=True ) @commands.command(name="voice_report") async def cmd_voice_report(self, ctx, mode: str = None): """Get an instant clinical summary of the current voice session. Use 'adv' for AI analysis.""" if not (ctx.author.id in self.bot.admin_ids or self.bot.has_whitelist_permission(ctx.author.id, 'wl')): return if not self.bot.voice_manager.is_monitoring: await ctx.send("◈ SYSTEM: Aucune session de surveillance vocale active actuellement.") return is_advanced = mode and (mode.lower() in ["adv", "advanced", "full", "ai", "llm"]) if is_advanced: await ctx.send("◈ SYSTEM: Lancement de l'analyse heuristique profonde (Gpt-Oss)...") async with ctx.typing(): report = await self.bot.voice_manager.generate_session_report(advanced=True) else: report = await self.bot.voice_manager.generate_session_report(advanced=False) await self.bot.messaging.send_embed( ctx.author, "INSTANT VOICE SESSION REPORT", report, color=discord.Color.blue(), is_asset=True ) async def setup_commands(bot): """Register all commands with the bot.""" # Channel commands await bot.add_cog(ChannelCommands(bot)) # Category commands await bot.add_cog(CategoryCommands(bot)) # Security commands await bot.add_cog(SecurityCommands(bot)) # Other commands await bot.add_cog(OtherCommands(bot)) # Bêta Expansion commands await bot.add_cog(BêtaExpansionCommands(bot))