Command

Command

The Command Object

Constructor

new Command(options, parentnullable)

Parameters:
Name Type Attributes Description
options CommandOptions

Option to be passed to the command.

parent Command <nullable>

Command will only have a parent if it is registered as a sub command

Source:

Members

(readonly) _comparator :string|regex|function|Array.<string>

Commands comparative function

Type:
  • string | regex | function | Array.<string>
Source:

(readonly) caseSensitive :boolean

If the command is case sensitive

Type:
  • boolean
Source:

description :string

The description of the command

Type:
  • string
Source:

(readonly) dmOnly :boolean

If the command can only be used in DM/GroupDM.

Type:
  • boolean
Source:

(readonly) guildOnly :boolean

If the command can only be used in a guild channel. Cannot be true is dmOnly is true.

Type:
  • boolean
Source:

(readonly) id :string

The ID of the command

Type:
  • string
Source:

names :Array.<string>

The aliases of the command

Type:
  • Array.<string>
Source:

subCommandAliases :Collection.<string>

Collection of subCommands aliases

Type:
  • Collection.<string>
Source:

subCommands :Collection.<Command>

Collection of subCommands

Type:
Source:

usage :string

The usage of the command

Type:
  • string
Source:

Methods

checkAuthorization(guildMember, guildChannel) → {boolean}

Method to check if a user has the proper permissions to

Parameters:
Name Type Description
guildMember external:GuildMember

The GuildMember to check for authorization

guildChannel external:GuildChannel

The GuildChannel the command was called in

Source:
Returns:
Type
boolean

registerSubCommand(CommandOrId, msgGeneratoropt, optionsopt)

Registers a command

Parameters:
Name Type Attributes Description
CommandOrId Command | string

The subCommand to register or the id to use

msgGenerator function | string | Array.<(string|function())> | falsy <optional>

The how to respond to the message

options CommandOptions <optional>

The options to pass to the subCommand

Source:

response(message, channel, args)

The function to be executed when the command is called

Parameters:
Name Type Description
message external:Message

The message that is running the command

channel external:GuildChannel | external:DMChannel | external:GroupDMChannel

The channel the command was executed in

args Array.<string>

command arguments

Source:

setAlias(alias)

Registers an alias for this command

Parameters:
Name Type Description
alias string | Array.<string>

A string or array of strings to set as an alias for the command

Source:

setSubAlias(subCommand, alias)

Registers an alias for a subCommand

Parameters:
Name Type Description
subCommand Command

The command to set an alias for

alias string | Array.<string>

t

Source: