Command

This defines the type for the user commands. Every Command is string with a callback function associated with it. We have flag variables to check whether the command requires input or media .

Properties



command    string

command to be typed to execute the callback function


callback    string[]

This is the function to be executed when the command is typed by the user. It should return an array of string, so that the bot send those as messages to the user.


requireMedia    boolean

Determines whether a media should be attached with the command. Default set to false.


requireInput    boolean

Determins whether the command needs an input value from the user.

Methods



equals(message)    boolean

Checks if the command is exactly equal to user message.


_requireInput()    void

This determines if the command requires input if the command has in the string then the command requires input. Note, this is a private function as indicated by ‘_’ sign. Also note, javascript does not have options to create a private function.


getInput(message)    object

Gets the input from the message. The message parameter is a type of Message that can provide us both the message string and media files. This is an async function because getting the image from message is an asynchronous procedure.

Returns an object with the input values mapped to the keys defined in command.


_getInputMessage(msgString)    object

Returns an object with input values that are strings. Only used for message with strings as input value.


_getSplitMessage(msg)    string[]

Returns a splitted message from msg string.


_getInputMedia(message)    object

Returns an object with input value that is a type of MessageMedia. Only used for message with media.