Command Constructor - Paultje52/BananenBase GitHub Wiki
To make sure that you can construct your commands properly, use the command constructor of the BananenBase. You can just extend your own command classes on this class.
The constructor is on: BananenBase.command
.
Constructor
First, the constructor. In your own constructor, call super
, to construct from the command constructor.
BananenBase
The first argument is the BananenBase object, that you get as the only parameter from your command constructor.
Basic options
Next, the basic options. This is an object with three possible values.
Name | Required | Default | Value type | Description |
---|---|---|---|---|
Name | Yes | X | String | The name of the command |
Description | No | String | The description of the command | |
Enabled | No | True | Boolean | If the command is enabled. |
Module options
To configure modules in your commands, add a new object for each module. This objects has two properties.
- Name: String, the module name
- Value: What the module wants, this is for each module different
You can add as many module options as you like, but for each module, you can only add one value!
super(BananenBase, {
// Settings
}, { // First module setting
name: "alias",
value: ["x"]
}, { // Second module settings
name: "security",
value: { permissionName: "botOwner" }
}, ...);
Client
The client object (BananenBase.client) is on this.client
after you called super
. The BananenBase object itself is on this._BananenBase
.
Ready
You can execute code when the bot is ready, by adding the ready
method to your class.
class MyCommand {
constructor(BananenBase) {
// ...
}
ready() {
// Do stuff when the bot is ready!
}
}
Run
To execute code when the command is used, add the run
method. It has to parameters.
- The message objects
- The args
class MyCommand {
constructor(BananenBase) {
// ...
}
run(message, args) {
// Do things when the command is executed!
}
}
If a module check isn't successful (Example, when someone doesn't have all the required permissions), the run
method isn't executed.