Commands

Navigate into your commands folder and make a file and name it anything.

The basic syntax for a command file is :

  module.exports = {
        name : 'COMMAND-NAME', // The name of your command
        description : 'A SHORT DESCRIPTION', // A brief description of what your command does
        permissions : [AN ARRAY OF PERMISSIONS] , // The permission you want the USER to have in order to run the command
        slash : false , // If you want this command to be a slash command as well set it to true.
        async execute({message , args , client}) {
            // CODE-HERE
        }
    }

You can use 5 parameters with execute function which are :

  • message :- Message Component of Legacy Command.

  • args :- Various arguments supplied to the command.

  • client : Client object.

  • interaction : Interaction Component of a slash command.

  • options : The options of the slash command.

Lets see how this works with an example.

module.exports = {
    name : 'say',
    description : 'Echoes what the user says',
    permissions : [Permissions.FLAGS.SEND_MESSAGES],
    slash : false,
    async execute({message , args}){
        await message.reply(`You said : **${args.join(' ')}**`)
    }
}

Here is the output !

Last updated