Skip to content

Setting up Commands

Follow the folder structure and create sub folders inside your command folder. Name these sub-folders as a category name for your command files. In order for commands to run when placed inside their respective sub-folders of the command folder, you need to set the properties for each command.

Here is a sample command example with the filename of "ping.js" and it's the command properties:

module.exports = {
    name: 'ping',  //name of command when using <prefix>ping
    description: 'Ping Pong Command!', // description of command
    aliases: ['p'],  // aliases of command
    guildOnly: true,  // guild command only?
    /**
    * @property {Number} permissions 
    * Permission Level of the command: 
    * 0 = Any User
        * 5 = Server Owner
        * 10 = Bot Owner
        * The permission level can be set and changed by updating the config.js file
    **/
    permissions: 0,  
    minArgs: 0,   // minimum arguments required to execute command
    usage: '',  // example of how to use / call the command
    execute(message, args, client) { // function named execute; define what the command does
        return message.channel.send({ content: 'Pong.'});
    },
};

Properties

name string
This is the command name

description string
This is the description of the command and its functionality

aliases Array<String>
This is the different abbreviation (aliases) of the command that you can use to call and execute the command

guildOnly boolean = false
This is set the command if it can only be used within a server or can be used within direct message with the bot

permissions number
This is the permission level value of who can execute the command. If set to 0, any user can run this command, 5 is the server owner and 10 is only the bot owner can run the command. For more details, please refer to the config file on the permission levels.

minArgs number
This is the minimum arguments required to execute the command

maxArgs number
This is the maximum arguments required to execute the command

customIds Object
An object containing interaction name properties that are an Array<string> containing the custom id names for button/autoComplete/userContext/modal interactions

usage string
Show by writing an example of how to execute the command using the command argument(s) in the command call Example: !ping

execute(message, args, client, level) Promise<Message>
This is a function that is invoked when the command is called to be executed

Property Type Required Description
message Message Class true This is the message object that represents a message on Discord.
args Array<string> false This is the arguments array that is required and sent by the user when the command gets executed.
client Discord.Client false This is the Discord client object.
level Number false This is the user's permission level.