Skip to main content

Command Methods

The Command class is the base class for creating bot commands. It contains several useful methods that can be used in child classes. Here's a brief description of each of these methods:

  • isExecutable(message: UserMessageContext): boolean: A method that checks if the command can be executed based on the incoming message. Returns true if the command can be executed and false otherwise.

  • execute(message: UserMessageContext, data: ICommandExecuteData): An abstract method that must be implemented in child classes. This method performs actions related to executing the command. It takes the incoming message and data as an ICommandExecuteData object.

  • onError(message: UserMessageContext, error: any): A method that is called when an error occurs while executing the command. By default, it simply throws an error, but you can override it in child classes to handle the error in some other way.