SlashCommands

Deep structure of slashcommands

Slash commands are derived from a pre-generated interactionCreate event, so they also have the same client-side properties as their parent.

Example of commands/slash/example.js
const { ApplicationCommandOptionType } = require("discord.js");

module.exports = {
    name: "example", // => name of command, required
    description: "Example command.", // Description of command, required.
    userPerms: ["Administrator"], // Optional, if not set, anyone can use the command.
    botPerms: ["Administrator"], // Optional, if not set the bot will not do permission checks
    options: [ // Optional, add secondary options to the command
        {
            name: "option",
            description: "Select an option",
            type: ApplicationCommandOptionType.String,
            required: true,
            choices: [
                { name: "One", value: "one-option" },
                { name: "Two", value: "two-option" },
            ]
        },
    ],

    run: async (client, interaction) => {

        await interaction.reply("Hello World");
        
    }};

Last updated