|
| 1 | +const { readdirSync } = require("fs"); |
| 2 | + |
| 3 | +// Example of how to make a Help SlashCommand |
| 4 | + |
| 5 | +module.exports = { |
| 6 | + name: "help", |
| 7 | + usage: '/help <command>', |
| 8 | + options: [ |
| 9 | + { |
| 10 | + name: 'command', |
| 11 | + description: 'What command do you need help', |
| 12 | + type: 'STRING', |
| 13 | + required: false |
| 14 | + } |
| 15 | + ], |
| 16 | + category: "Bot", |
| 17 | + description: "Return all commands, or one specific command!", |
| 18 | + ownerOnly: false, |
| 19 | + run: async (client, interaction) => { |
| 20 | + |
| 21 | + // Buttons that take you to a link |
| 22 | + // If you want to delete them, remove this part of |
| 23 | + // the code and in line: 62 delete ", components: [row]" |
| 24 | + const row = new client.discord.MessageActionRow() |
| 25 | + .addComponents( |
| 26 | + new client.discord.MessageButton() |
| 27 | + .setLabel("GitHub") |
| 28 | + .setStyle("LINK") |
| 29 | + .setURL("https://github.com/Expectatives/Discord.js-v13-Example"), |
| 30 | + new client.discord.MessageButton() |
| 31 | + .setLabel("Support") |
| 32 | + .setStyle("LINK") |
| 33 | + .setURL("https://dsc.gg/faithcommunity") |
| 34 | + ); |
| 35 | + |
| 36 | + const commandInt = interaction.options.getString("command"); |
| 37 | + if (!commandInt) { |
| 38 | + |
| 39 | + // Get the slash commands of a Bot category |
| 40 | + const botCommandsList = []; |
| 41 | + readdirSync(`./slashCommands/Bot`).forEach((file) => { |
| 42 | + const filen = require(`../../slashCommands/Bot/${file}`); |
| 43 | + const name = `\`${filen.name}\`` |
| 44 | + botCommandsList.push(name); |
| 45 | + }); |
| 46 | + |
| 47 | + // Get the slash commands of a Utility category |
| 48 | + const utilityCommandsList = []; |
| 49 | + readdirSync(`./slashCommands/Utility`).forEach((file) => { |
| 50 | + const filen = require(`../../slashCommands/Utility/${file}`); |
| 51 | + const name = `\`${filen.name}\`` |
| 52 | + utilityCommandsList.push(name); |
| 53 | + }); |
| 54 | + |
| 55 | + // This is what it commands when using the command without arguments |
| 56 | + const helpEmbed = new client.discord.MessageEmbed() |
| 57 | + .setTitle(`${client.user.username} SlashHelp`) |
| 58 | + .setDescription(` Hello **<@${interaction.member.id}>**, I am <@${client.user.id}>. \nYou can use \`/help <slash_command>\` to see more info about the SlashCommands!\n**Total Commands:** ${client.commands.size}\n**Total SlashCommands:** ${client.slash.size}`) |
| 59 | + .addField("🤖 - Bot SlashCommands", botCommandsList.map((data) => `${data}`).join(", "), true) |
| 60 | + .addField("🛠 - Utility SlashCommands", utilityCommandsList.map((data) => `${data}`).join(", "), true) |
| 61 | + .setColor(client.config.embedColor) |
| 62 | + .setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` }); |
| 63 | + |
| 64 | + interaction.reply({ embeds: [helpEmbed], components: [row] }); |
| 65 | + } else { |
| 66 | + const command = client.slash.get(commandInt.toLowerCase()); |
| 67 | + |
| 68 | + // This is what it sends when using the command with argument and it does not find the command |
| 69 | + if (!command) { |
| 70 | + interaction.reply({ content: `There isn't any SlashCommand named "${commandInt}"` }); |
| 71 | + } else { |
| 72 | + |
| 73 | + // This is what it sends when using the command with argument and if it finds the command |
| 74 | + let command = client.slash.get(commandInt.toLowerCase()); |
| 75 | + let name = command.name; |
| 76 | + let description = command.description || "No descrpition provided" |
| 77 | + let usage = command.usage || "No usage provided" |
| 78 | + let category = command.category || "No category provided!" |
| 79 | + |
| 80 | + let helpCmdEmbed = new client.discord.MessageEmbed() |
| 81 | + .setTitle(`${client.user.username} Help | \`${(name.toLocaleString())}\` SlashCommand`) |
| 82 | + .addFields( |
| 83 | + { name: "Description", value: `${description}` }, |
| 84 | + { name: "Usage", value: `${usage}` }, |
| 85 | + { name: 'Category', value: `${category}` }) |
| 86 | + .setColor(client.config.embedColor) |
| 87 | + .setFooter({ text: `${client.config.embedfooterText}`, iconURL: `${client.user.displayAvatarURL()}` }); |
| 88 | + |
| 89 | + interaction.reply({ embeds: [helpCmdEmbed] }); |
| 90 | + } |
| 91 | + } |
| 92 | + }, |
| 93 | +}; |
0 commit comments