After you have created your bot, you can start adding commands to it.
To add commands you have to use the bot.addCommand(name, handler, documentation?) method.
For example:
bot.addCommand("ping", () => "pong", {
description: "Ping the bot",
explanation: "This command is used to ping the bot in order to check if it is working",
example: {
input: "test",
output: "pong",
},
});This method takes three arguments:
The name of the command. This is the name that the user will have to type to execute the command.
- Value type:
string - required:
true
This is a function that will be executed when the user types the command name followed by the bot symbol.
The Message and Client types will be specified on the class that implements the bot builder, they extend the BaseMessage and EventEmitter types respectively.
If there is, the returned value will be sent to the user as a message. If not, nothing will be sent.
- Value type:
(message?: Message, client?: Client) => string | number | void - required:
true
The documentation of the command. This is an object that contains information about the command.
- Value type: Documentation
- Required:
false
The Message type is a generic type that extends the BaseMessage (and implement the reply method). It could have many properties depending on the implementation of the bot builder, but due to this library command's processing, it will at least have the following properties:
The name of the command that was executed.
- Value type:
string
The text that the user typed after the command name.
- Value type:
string
The array containing every word that the user typed after the command name.
- Value type:
string[]
The function that the bot will use to reply to the user.
- Value type:
reply: (...args) => Promise<any>
The Client type is a generic type that extends the EventEmitter.
The Documentation type is an object that contains information about the command.
- description
- explanation
- example
- input
- output
Short description of the command. It will be listed on the general help command. If there isn't a description, it will just list the name without any description.
For example, the ping command's description is: Ping the bot
- Value type:
string
Longer explanation of the command. It will be listed on the specific help command. If there isn't an explanation, the description will be sent instead; if there isn't documentation at all, it will reply This command has no documentation.
For example, the ping command's explanation is: This command is used to ping the bot in order to check if it is working
- Value type:
string
An example of the command usage. It will be listed on the specific help command. If there isn't an example, nothing will be sent.
Both the input and the output are optional.
In this case, the input is empty, and the output is pong.
In this one, the input is test, and the output is still pong.
Last, but not least, in this case, the input is test, and the output is empty.
- Value type:
Object- input:
string - output:
string
- input:




