Class: Command

Command(name, options, run, response, responseDM)

Class representing a command.

Constructor

new Command(name, options, run, response, responseDM)

Create a command.
Parameters:
Name Type Description
name string | Array The name of the command. If passed as an array, the first item of the array is used as the name and the rest of the items are set as aliases.
options object Options of command
Properties
Name Type Attributes Default Description
category string <optional>
'Default' Category from this command
help string <optional>
'' Description of command
args string <optional>
'' The command arguments
hide boolean <optional>
false Hide command from default help command
enable boolean <optional>
true Enable/Disable the command
childOf string <optional>
Parent command name
requirements Array <optional>
[] Requirements are mapped in client.addCommand
hooks object <optional>
{} Command hooks.
Properties
Name Type Attributes Default Description
pre Array.<function()> <optional>
[] Hook pre run command.
executed Array.<function()> <optional>
[] Hook after run command.
error Array.<function()> <optional>
[] Hook fired when there an error with execution command.
custom object <optional>
{} Define custom methods or properties to copy to command.
run Command~run The function to be called when the command is executed.
response string | function | EmbedMessageObject Response to command. Ignore run function.
responseDM string | function | EmbedMessageObject DM response to command. Ignore run function.
Source:

Members

aliases

Properties:
Type Description
Array.<string> Command aliases
Source:

args

Properties:
Type Description
string Arguments for a command
Source:

category

Properties:
Type Description
string Command category. It should exist if not, will be 'Default'
Source:

childOf

Properties:
Type Description
string | undefined Name of uppercomand
Source:

childs

Properties:
Type Description
Array.<Command> Subcommands of Command.
Source:

client

Properties:
Type Description
Client Client instance
Source:

custom

Properties:
Type Description
object | undefined Custom props
Source:

enable

Properties:
Type Description
boolean Enable/Disable the command
Source:

help

Properties:
Type Description
string Description of command
Source:

hide

Properties:
Type Description
boolean Hide to default help command
Source:

hooks

Properties:
Type Description
object Command Hooks
Source:

names

All names that can be used to invoke the command - its primary name in addition to its aliases.
Source:

parent

Properties:
Type Description
Command | undefined Parent Command
Source:

requirements

Properties:
Type Description
array Command Requirements
Source:

response

Properties:
Type Description
string | EmbedMessageObject | function Response of command. If it exists, ignore run function. If function (msg, args, client, commad)
Source:

responseDM

Properties:
Type Description
string | EmbedMessageObject | function Response of command with a direct message. If it exists, ignore run function. If function (msg, args, client, commad)
Source:

run

Properties:
Type Description
Command~run Run function of command
Source:

Methods

addHook(hookname, hook)

Add a hook
Parameters:
Name Type Description
hookname string Hook name.
hook CommandHook Hook to add.Inject a method to remove it.
Source:

addRequirement(requirement)

Add a requirement
Parameters:
Name Type Description
requirement object Requirement to add. Inject a method to remove it.
Source:

error()

Throw a command error
Source:

removeHook(hookname, hook)

Remove a hook
Parameters:
Name Type Description
hookname string Hook name.
hook CommandHook Hook to remove.
Source:

removeRequirement(requirement)

Remove a requirement
Parameters:
Name Type Description
requirement object Requirement to remove.
Source:

Type Definitions

run(msg, args, client, command)

Parameters:
Name Type Description
msg Eris.Message The Eris message object that triggered the command. For more information, see the Eris documentation: https://abal.moe/Eris/docs/Message
args args An array of arguments passed to the command, obtained by removing the command name and prefix from the message, then splitting on spaces. To get the raw text that was passed to the command, use `args.join(' ')`.
client Client client instance that recieved the message triggering the command.
command Command The name or alias used to call the command in the message. Will be one of the values of `this.names`.
Source: