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.
Usage
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
This is the command name
Type: string
description
The is the description of the command and its functionality
Type: string
aliases
The is the different abbreviation (aliases) of the command that you can use to call and execute the command
Type: Array<String>
guildOnly
This is set the command if its can only be used within a server or can be used within direct message with the bot
Type: Boolean
Default: false
permissions
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.
Type: Number
minArgs
This is the minimum arguments required to execute the command
Type: Number
maxArgs
This is the maximum arguments required to execute the command
Type: Number
Default: 0
**execute(**message, args, client, level)
This a function that is invoked when the command is called to be executed
args
Array<string>
false
This is arguments array that is required and sent by the user when the command gets executed.
level
Number
false
This is the user's permission level.
returns;
Last updated