CommandDispatcher

new CommandDispatcher(bot: Bot)

Handles dispatching commands
Parameters:
Name Type Description
bot
Bot
Bot instance

Methods

.checkLimiter(dm: boolean, message: Message, command: Command) → boolean

Check of the command caller has roles that pass the command limiter set by the guild admins if the command is called within a guild
Parameters:
Name Type Description
dm
boolean
Whether the message is a DM
message
Message
Discord.js message object
command
Command
Command found by the dispatcher
Returns:
boolean

.checkPermissions(dm: boolean, message: Message, command: Command) → Array<PermissionResolvable>

Get a list of missing permissions for the command caller for the given command, if any
Parameters:
Name Type Description
dm
boolean
Whether the message is a DM
message
Message
Discord.js message object
command
Command
Command found by the dispatcher
Returns:
Array<PermissionResolvable>

.commandNotFoundError(message: Message) → Promise<Message>

Send a 'command not found' error message to the channel
Parameters:
Name Type Description
message
Message
Discord.js message object
Returns:
Promise<Message>

.dispatch(command: Command, message: Message, args: Array<args>, mentions: Array<User>, original: string) → Promise<*>

Pass the necessary items to the found Command's Command#action method
Parameters:
Name Type Description
command
Command
The command found by the dispatcher
message
Message
Discord.js message object
args
Array<args>
An array containing the args parsed from the command calling message
mentions
Array<User>
An array containing the Discord.js User objects parsed from the mentions contained in a message
original
string
The original raw content of the message that called the command
Returns:
Promise<*>

.failedLimiterError(message: Message, command: Command) → Promise<Message>

Send a 'missing roles for role-limited command' error message to the channel
Parameters:
Name Type Description
message
Message
Discord.js message object
command
Command
Command found by the dispatcher
Returns:
Promise<Message>

.guildOnlyError(message: Message) → Promise<Message>

Send a 'guild only' error message to the channel
Parameters:
Name Type Description
message
Message
Discord.js message object
Returns:
Promise<Message>

.handleMessage(message: Message) → *

Determine if message is a valid command call and send to CommandDispatcher#dispatch
Parameters:
Name Type Description
message
Message
Discord.js message object
Returns:
*

.hasRoles(dm: boolean, message: Message, command: Command) → boolean

Checks if the command caller has roles for the given command
Parameters:
Name Type Description
dm
boolean
Whether the message is a DM
message
Message
Discord.js message object
command
Command
Command found by the dispatcher
Returns:
boolean

.missingPermissionsError(missing: Array<PermissionResolvable>, message: Message) → Promise<Message>

Send a 'missing permissions' error message to the channel
Parameters:
Name Type Description
missing
Array<PermissionResolvable>
Array of missing permissions
message
Message
Discord.js message object
Returns:
Promise<Message>

.missingRolesError(message: Message, command: Command) → Promise<Message>

Send a 'missing roles' error message to the channel
Parameters:
Name Type Description
message
Message
Discord.js message object
command
Command
Command found by the dispatcher
Returns:
Promise<Message>

.processContent(message: Message) → Object

Processes message content, finding the command to execute and creating an object containing the found command, mentions, args, processed content, and if the message is a DM
Parameters:
Name Type Description
message
Message
Discord.js message object
Returns:
Object