const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } = require("discord.js") module.exports = { name: 'help', description: 'Affiche la liste des commandes', category: 'utils', emote: '📚', utilisation: 'help [commande]', async execute(message, args, client) { if (args[0]) { // L'utilisateur a fourni un argument, affichez l'aide pour cette commande const command = client.commands.get(args[0]); if (!command) { return message.reply(`Je n'ai pas trouvĂ© de commande nommĂ©e "${args[0]}".`); } const embed_command = new EmbedBuilder() .setColor('#0099ff') .setTitle(`Aide pour la commande ${command.emote ? ` ${command.emote}` : '🔧'} ${command.name}`) .setDescription(command.description) .addFields( { name: 'Utilisation', value: `\`+${command.utilisation ? ` **${command.utilisation}**` : ''}\``, inline: true }, { name: 'CatĂ©gorie', value: command.category || 'Non spĂ©cifiĂ©e', inline: true } ); return message.reply({ embeds: [embed_command] }); } const categories = { antiraid: [], botcontrol: [], game: [], gestion: [], utils: [], other: [], }; for (const command of client.commands.values()) { if (command.category) { categories[command.category].push({ name: command.name, description: command.description, emote: command.emote, utilisation: command.utilisation}); } } let description = 'SĂ©lectionnez une catĂ©gorie parmi les options ci-dessous pour obtenir de l\'aide sur les commandes correspondantes.\n\n'; for (const [category, commands] of Object.entries(categories)) { description += `**CatĂ©gorie ${category}**\n`; description += commands.length > 0 ? '> ' + commands.map(command => `\`${command.name}\``).join(', ') : '> Aucune commande dans cette catĂ©gorie'; description += '\n\n'; } const embeds = { home: new EmbedBuilder() .setColor('#0099ff') .setTitle('📚 Information') .setDescription(description) .setThumbnail(message.guild.iconURL()) }; // CrĂ©ez un embed pour chaque catĂ©gorie for (const [category, commands] of Object.entries(categories)) { let description; if (commands.length > 0) { description = commands.map(command => `${command.emote ? ` ${command.emote}` : '🔧'} **+${command.utilisation ? ` ${command.utilisation}` : ''}**\n \`${command.description}\``).join('\n'); } else { description = 'Aucune commande dans cette catĂ©gorie.'; } embeds[category] = new EmbedBuilder() .setColor('#0099ff') .setTitle(`CatĂ©gorie ${category}`) .setDescription(description); } const menu = new StringSelectMenuBuilder() .setCustomId('help_menu') .setPlaceholder('SĂ©lectionnez une catĂ©gorie') .addOptions([ { label: 'Accueil', value: 'home' }, ...Object.keys(categories).map(category => ({ label: `CatĂ©gorie ${category}`, value: category })), ]); const row = new ActionRowBuilder() .addComponents(menu); const sentMessage = await message.reply({ embeds: [embeds.home], components: [row] }); const filter = i => i.customId === 'help_menu' && i.user.id === message.author.id; const collector = sentMessage.createMessageComponentCollector({ filter, time: 60000 }); collector.on('collect', async (interaction) => { await interaction.update({ embeds: [embeds[interaction.values[0]]] }); }); collector.on('end', () => { sentMessage.edit({ components: [] }); }); }, };