How Commands Work
Everything you need to know about CommandKit
CommandKit is the way this tutorial teaches you how to manage your Discord commands and events without using an event handler, which can get very complicated.
This page will go over the basics of CommandKit and if you would like to learn more, watch This video.
Commands
To handle commands, CommandKit also uses style,
module.exports = {
data:
run: ({}) => {}
options: {}
}where it exports 3 functions: data, run, and options.
Data
Data is where you input the actual physical data for your slash command. This includes its name and its description. This can also be options (for the application command) if you would like it to be.
Run
This is where your executed code will stay. When the command is ran, it will first run validations then will run the contents of the run function. You can also make this function async by adding async before the first set of parentheses and curly braces.
Inside the first set of curly braces, you can destructure parts of your interaction, such as interaction, client, and handler to use later on in your code as referral points.
The second set of curly braces will contain your code for when the command is executed.
Options
Options are used to change the properties of your command, and can also be used to create new options for validations. Such as adding cooldowns to commands.
The options function can take the following:
devOnly?- BooleanuserPermissions- Array of StringsbotPermissions- Array of Stringsdeleted?- Boolean
Last updated