Constructor
new Command()
- Source:
Properties:
Name |
Type |
Description |
aliases |
Array.<string>
|
|
shortDescription |
string
|
|
longDescription |
string
|
|
usageExample |
string
|
|
aliasesForHelp |
Array.<string>
|
The aliases that should be displayed in the help command. |
hidden |
boolean
|
True if information about this command should not be shown by the help command. |
Type Definitions
CommandDefinition
- Description:
- A definition of one command. Each command definition should
be a module in your commands directory (specified as a constructor option to Monochrome).
Each command definition file should export one command definition.
- Source:
Properties:
Name |
Type |
Attributes |
Default |
Description |
commandAliases |
Array.<string>
|
|
|
The part of the command that follows the prefix. For example if
your prefixes (specified as a constructor option to Monochrome) contain "command!"" and your command
aliases contain "ping", then "command!ping" will trigger this command (if the prefix has not been customized in the server). |
uniqueId |
string
|
|
|
A unique ID to identify the command. This can be anything, and won't be shown to users. You should
never change it. |
action |
Command~commandAction
|
|
|
A function to perform the command. |
cooldown |
number
|
<optional>
|
0
|
A period of time (in seconds) to prevent that user from using this command after they previously used it. |
shortDescription |
string
|
<optional>
|
|
A brief description of what the command does. This is intended to be displayed by the help command.
If "<prefix>" is present in this string, it will be replaced with the primary command prefix in the server. |
longDescription |
string
|
<optional>
|
|
A longer description of what the command does. This is intended to be displayed by the help command when
the user requests to see the advanced help for the command. If "<prefix>" is present in this string, it will be replaced with the primary
command prefix in the server. |
usageExample |
string
|
<optional>
|
|
An example of how to use the command. If "<prefix>" is present in this string, it will be replaced with the primary
command prefix in the server. |
botAdminOnly |
boolean
|
<optional>
|
false
|
If true, only a bot admin can use this command. Bot admins are specified as a constructor option to Monochrome. |
canBeChannelRestricted |
boolean
|
<optional>
|
!botAdminOnly
|
If true, server admins can disable this command in any channel in their server. |
requiredSettings |
Array.<string>
|
<optional>
|
[]
|
An array of setting unique IDs that are required for this command. When this command is invoked, the values of
those settings are looked up and passed into your commandAction function. |
aliasesForHelp |
Array.<string>
|
<optional>
|
|
If you don't want to show some of the command aliases in the help, you can specify which ones you do want to show here.
By default, all aliases are shown in the help. |
requiredBotPermissions |
Array.<string>
|
<optional>
|
|
The permissions that the bot must have in order to execute the command. See Eris.Constants.Permissions at https://abal.moe/Eris/docs/reference. |
A definition of one command. Each command definition should
be a module in your commands directory (specified as a constructor option to
Monochrome).
Each command definition file should export one command definition.
Type:
Example
module.exports = {
commandAliases: ['ping', 'p'],
uniqueId: 'ping',
cooldown: 5,
shortDescription: 'You say <prefix>ping, I say pong.',
longDescription: 'This command is really useless and has no need for a long description but ¯\_(ツ)_/¯',
usageExample: '<prefix>ping',
botAdminOnly: false,
canBeChannelRestricted: true,
requiredSetting: ['unique_id_of_some_setting'],
aliasesForHelp: ['ping'],
requiredBotPermissions: ['readMessages', 'sendMessages'],
action(bot, msg, suffix, monochrome, requestedSettings) {
return msg.channel.createMessage('Pong!', null, msg);
},
};
commandAction(bot, msg, suffix, monochrome, settings) → {Promise|undefined}
- Description:
- A function to perform a command. This function is invoked when a user message
starts with the server's command prefix plus one of the command's aliases.
- Source:
Parameters:
Name |
Type |
Description |
bot |
external:"Eris.Client"
|
|
msg |
external:"Eris.Message"
|
The message that triggered the command |
suffix |
string
|
The part of the message that follows the command invocation (i.e. for "prefix!command do the command", the prefix is "do the command") |
monochrome |
Monochrome
|
|
settings |
Object
|
The requested setting values. The keys of this object are the setting unique IDs, and the values are the settings values. |
Returns:
If a promise is returned, it will be resolved, and if it rejects, that error will be logged and handled. In general, your
commands should return promises.
-
Type
-
Promise
|
undefined