const { SlashCommandBuilder } = require('@discordjs/builders'); const { CommandInteraction, MessageActionRow, MessageSelectMenu, Formatters } = require('discord.js'); const Discord = require('discord.js'); module.exports = { ...new SlashCommandBuilder() .setName('help') .setDescription('Shows the list of commands, or info on a single command') .addStringOption((option) => option.setName('command').setDescription('ok')), run: async (client, interaction, args) => { const cmd = interaction.options.getString("command"); if (cmd) { let command = await client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd)) /* error embed */ const errEmbed = new Discord.MessageEmbed() .setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({ dynamic: true })) .setDescription(`${client.emotes.no} No such command found with the name or alias(es) of, \`${cmd}\``) .setColor('#FF0000') /* error embed*/ if (!command || command.help.category === "Tests" || command.help.category === "Developer") { return interaction.followUp({ embeds: [errEmbed] }); }; /* embed */ const embed = new Discord.MessageEmbed() .setTitle(`Command: ${command.name}`) .setDescription(`${command.help.description}`) .addField('Usage', `\`${command.help.usage}\``, true) .addField('Example', `\`${command.help.example}\``, true) .addField('Cooldown', `\`${command.help.cooldown}\``, true) .addField('Aliases', `\`${command.aliases.join(", ")}\``,true) .addField('Category', `\`${command.help.category}\``, true) .addField('Required Permissions', `\`${command.help.requiredPerms}\``, true) .addField('Required Permissions (Bot)', `\`${command.help.botPerms}\``, true) .setFooter('[] stands for optional arguments, while <> stands for required arguments') .setColor(client.config.color) /* embed */ return interaction.followUp({ embeds: [embed] }); } else if (!cmd) { const row = new MessageActionRow() .addComponents( new MessageSelectMenu() .setCustomId('select') .setPlaceholder('Help menu') .addOptions([ { label: 'Fun', description: 'Get the command list for the "fun" category!', value: 'fun_module', emoji: client.emotes.skeletonVibe, }, { label: 'Moderation', description: 'Get the command list for the "moderation" category!', value: 'mod_module', emoji: client.emotes.modShield, }, ]), ); /* embeds */ const funModule = new Discord.MessageEmbed() .setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({ dynamic: true })) .setTitle("Fun Module") .setDescription(Formatters.codeBlock('js', 'hero-info')) .setColor(client.config.color) const modModule = new Discord.MessageEmbed() .setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({ dynamic: true })) .setTitle("Moderation Module") .setDescription(Formatters.codeBlock('js', 'prefix, snipe')) .setColor(client.config.color) /* embeds */ const msg = await interaction.followUp({ content: 'Select Menu', components: [row] }); const collector = interaction.channel.createMessageComponentCollector({ componentType: 'SELECT_MENU', time: 120000 }); collector.on('collect', async i => { if (i.user.id !== interaction.user.id) { await i.reply({ content: "You can't press this button!", ephemeral: true, }); return; }; if (i.values[0] === "fun_module") { i.reply({ embeds: [funModule], ephemeral: true }); } else if (i.values[0] === "mod_module") { i.reply({ embeds: [modModule], ephemeral: true }); }; }); collector.on('end', async i => { msg.edit({ content: 'This message has expired!', components: [] }); }); }; }, };