Constructor
new Command(label, generator, optionsopt)
Register a command
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
aliases |
Array.<String>
|
An array of command aliases |
|
argsRequired |
Boolean
|
If arguments are required or not |
|
caseInsensitive |
Boolean
|
Whether the command label (and aliases) is case insensitive or not |
|
cooldown |
Number
|
The cooldown between command usage in milliseconds |
|
cooldownExclusions |
Object
|
A set of factors that limit where cooldowns are active |
|
cooldownMessage |
function
|
String
|
A string or a function that returns a string to show when the command is on cooldown. |
|
cooldownReturns |
Number
|
Number of times to return a message when the command is used during it's cooldown. |
|
defaultSubcommandOptions |
Object
|
Default subcommand options. |
|
deleteCommand |
Boolean
|
Whether to delete the user command message or not |
|
description |
String
|
A short description of the command |
|
dmOnly |
Boolean
|
Whether the command is prevented from being used in guilds or not |
|
errorMessage |
function
|
String
|
A string or a function that returns a string to show if the execution of the command handler somehow fails. The function is passed the Message object as a parameter. |
|
fullDescription |
String
|
A detailed description of the command |
|
fullLabel |
String
|
The full command label |
|
guildOnly |
Boolean
|
Whether the command is prevented from being used in Direct Messages or not |
|
hidden |
Boolean
|
Whether or not the command is hidden from the default help command list. |
|
hooks |
Object
|
A set of functions to be executed at different times throughout the command's processing |
|
invalidUsageMessage |
function
|
String
|
A string or a function that returns a string to show when a command was improperly used. |
|
label |
String
|
The command label |
|
parentCommand |
Command
|
<nullable> |
If this command is also a subcommand, this will refer to its parent Command |
permissionMessage |
function
|
String
|
A string or a function that returns a string to show when the user doesn't have permissions to use the command. |
|
reactionButtons |
Object
|
<nullable> |
An array of objects specifying reaction buttons, or null if no reaction buttons. |
reactionButtonTimeout |
Number
|
Time (in milliseconds) to wait before invalidating the command's reaction buttons |
|
requirements |
Object
|
A set of factors that limit who can call the command |
|
restartCooldown |
Boolean
|
Whether or not to restart a command's cooldown every time it's used |
|
subcommands |
Object
|
Object mapping subcommand labels to Command objects |
|
subcommandAliases |
Object
|
Object mapping subcommand aliases to their respective subcommand label |
|
usage |
String
|
Details on how to call the command to show in the default help command |
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
label |
String
|
The command label |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
generator |
function
|
String
|
Array.<(function()|String)>
|
A response string, array of functions or strings, or function that generates a string or array of strings when called.
If a function is passed, the function will be passed a Message object and an array of command arguments. The Message object will have an additional property |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object
|
<optional> |
Command options
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
option.cooldownReturns |
Number
|
<optional> |
0 |
Number of times to return a message when the command is used during it's cooldown. Once the cooldown expires this is reset. Set this to 0 to always return a message. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.defaultSubcommandOptions |
Object
|
<optional> |
{} |
Default subcommand options. This object takes the same options as a normal Command |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.deleteCommand |
Boolean
|
<optional> |
false |
Whether to delete the user command message or not |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.description |
String
|
<optional> |
"No description" |
A short description of the command to show in the default help command |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.dmOnly |
Boolean
|
<optional> |
false |
Whether to prevent the command from being used in guilds or not |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.errorMessage |
function
|
String
|
Object
|
<optional> |
A string or |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.fullDescription |
String
|
<optional> |
"No full description" |
A detailed description of the command to show in the default help command |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.guildOnly |
Boolean
|
<optional> |
false |
Whether to prevent the command from being used in Direct Messages or not |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.hidden |
Boolean
|
<optional> |
false |
Whether or not the command should be hidden from the default help command list. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.hooks |
Object
|
<optional> |
A set of functions to be executed at different times throughout the command's processing
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.invalidUsageMessage |
function
|
String
|
Object
|
<optional> |
A string or |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.permissionMessage |
function
|
String
|
Object
|
<optional> |
A string or |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.reactionButtons |
Array.<{emoji: String, type: String, response: (function()|String|Array.<(function()|String)>), filter: function()}>
|
<optional> |
An array of objects specifying reaction buttons
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.reactionButtonTimeout |
Number
|
<optional> |
60000 |
Time (in milliseconds) to wait before invalidating the command's reaction buttons |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.requirements |
Object
|
<optional> |
A set of factors that limit who can call the command
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
option.restartCooldown |
Boolean
|
<optional> |
false |
Whether or not to restart a command's cooldown every time it's used. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.usage |
String
|
<optional> |
Details on how to call the command to show in the default help command |
Methods
registerSubcommand(label, generator, optionsopt) → {Command}
Register a subcommand
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
label |
String
|
The subcommand label |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
generator |
function
|
String
|
Array.<(function()|String)>
|
A response string, array of functions or strings, or function that generates a string or array of strings when called.
If a function is passed, the function will be passed a Message object and an array of subcommand arguments. The Message object will have an additional property |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object
|
<optional> |
Command options
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
option.cooldownReturns |
Number
|
<optional> |
0 |
Number of times to return a message when the command is used during it's cooldown. Once the cooldown expires this is reset. Set this to 0 to always return a message. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.defaultSubcommandOptions |
Object
|
<optional> |
{} |
Default subcommand options. This object takes the same options as a normal Command |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.deleteCommand |
Boolean
|
<optional> |
false |
Whether to delete the user command message or not |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.description |
String
|
<optional> |
"No description" |
A short description of the command to show in the default help command |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.dmOnly |
Boolean
|
<optional> |
false |
Whether to prevent the command from being used in guilds or not |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.errorMessage |
function
|
String
|
Object
|
<optional> |
A string or |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.fullDescription |
String
|
<optional> |
"No full description" |
A detailed description of the command to show in the default help command |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.guildOnly |
Boolean
|
<optional> |
false |
Whether to prevent the command from being used in Direct Messages or not |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.hidden |
Boolean
|
<optional> |
false |
Whether or not the command should be hidden from the default help command list |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.hooks |
Object
|
<optional> |
A set of functions to be executed at different times throughout the command's processing
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.invalidUsageMessage |
function
|
String
|
Object
|
<optional> |
A string or |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.permissionMessage |
function
|
String
|
Object
|
<optional> |
A string or |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.reactionButtons |
Array.<{emoji: String, type: String, response: (function()|String|Array.<(function()|String)>)}>
|
<optional> |
An array of objects specifying reaction buttons
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
options.reactionButtonTimeout |
Number
|
<optional> |
60000 |
Time (in milliseconds) to wait before invalidating the command's reaction buttons |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.requirements |
Object
|
<optional> |
A set of factors that limit who can call the command
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
option.restartCooldown |
Boolean
|
<optional> |
false |
Whether or not to restart a command's cooldown every time it's used. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
options.usage |
String
|
<optional> |
Details on how to call the command to show in the default help command |
Returns:
- Type:
-
Command
registerSubcommandAlias(alias, label)
Register an alias for a subcommand
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
alias |
String
|
The alias |
label |
String
|
The original subcommand label |
unregisterSubcommand(label)
Unregister a subcommand
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
label |
String
|
The subcommand label |