CommandDispatcher
Extends:
Handles parsing messages and running commands from them
Static Method Summary
Static Public Methods | ||
public static |
makeResultObject(result: CommandResult | string[] | string): CommandResult Makes a command result object from a command's run result |
|
public static |
Parses an argument string into an array of arguments |
Constructor Summary
Public Constructor | ||
public |
constructor(bot: Bot) |
Method Summary
Public Methods | ||
public |
handleMessage(message: Message, oldMessage: Message): Promise<null> Handle a new message or a message update |
|
public |
handleMessageResult(message: Message, result: CommandResult, oldResult: CommandResult): Promise<null> Handle a message result |
|
public |
run(command: Command, args: string[], fromPattern: boolean, message: Message): Promise<CommandResult> Run a command |
|
public |
Sends messages |
|
public |
sendMessagesForResult(message: Message, result: CommandResult): Promise<null> Sends messages for a command result |
|
public |
updateMessages(message: Message, oldMessages: Message[], contents: string[], type: string): Promise<Message[]> Updates messages |
|
public |
updateMessagesForResult(message: Message, result: CommandResult, oldResult: CommandResult): Promise<null> Updates messages for a command result |
Static Public Methods
public static makeResultObject(result: CommandResult | string[] | string): CommandResult source
Makes a command result object from a command's run result
Params:
Name | Type | Attribute | Description |
result | CommandResult | string[] | string | The command's run result |
public static parseArgs(argString: string, argCount: number, allowSingleQuote: boolean): string[] source
Parses an argument string into an array of arguments
Params:
Name | Type | Attribute | Description |
argString | string | The argument string to parse |
|
argCount | number |
|
The number of arguments to extract from the string |
allowSingleQuote | boolean |
|
Whether or not single quotes should be allowed to wrap arguments, in addition to double quotes |
Public Constructors
Public Methods
public handleMessage(message: Message, oldMessage: Message): Promise<null> source
Handle a new message or a message update
public handleMessageResult(message: Message, result: CommandResult, oldResult: CommandResult): Promise<null> source
Handle a message result
Params:
Name | Type | Attribute | Description |
message | Message | The message the result is from |
|
result | CommandResult |
|
The result |
oldResult | CommandResult |
|
The old result |
public run(command: Command, args: string[], fromPattern: boolean, message: Message): Promise<CommandResult> source
Run a command
Emit:
* |
commandRun When a command is run, with the command, result, message, args, and fromPattern passed |
* |
commandError When an error occurs while running a command, with the command, message, args, and fromPattern passed |
public sendMessages(message: Message, contents: string[], type: string): Promise<Message[]> source
Sends messages
public sendMessagesForResult(message: Message, result: CommandResult): Promise<null> source
Sends messages for a command result
Params:
Name | Type | Attribute | Description |
message | Message | The message the result is for |
|
result | CommandResult | The command result |
public updateMessages(message: Message, oldMessages: Message[], contents: string[], type: string): Promise<Message[]> source
Updates messages
public updateMessagesForResult(message: Message, result: CommandResult, oldResult: CommandResult): Promise<null> source
Updates messages for a command result
Params:
Name | Type | Attribute | Description |
message | Message | The message the result is for |
|
result | CommandResult | The command result |
|
oldResult | CommandResult | The old command result |