CommandLoader

CommandLoader

Handles the loading of commands

Constructor

new CommandLoader(clientopt)

Source:
Parameters:
Name Type Attributes Description
client ModzClient <optional>
Client to use

Members

aliases :Collection.<string, Command>

The loaded aliases
Source:
Type:

(readonly) Client :ModzClient

The client the loader is serving
Source:
Type:

commands :Collection.<string, Command>

The loaded commands
Source:
Type:

(nullable) commandsPath :string

The path to the commands
Source:
Type:
  • string

defaultCommands :Array.<string>

The path to the commands
Source:
Type:
  • Array.<string>

Methods

findCommands(searchStringopt, exactopt) → {Array.<Command>}

Finds all commands that match the search string
Source:
Parameters:
Name Type Attributes Default Description
searchString string <optional>
null The string to search for
exact boolean <optional>
false Whether the search should be exact
Returns:
Type:
Array.<Command>
All commands that are found

loadCommand(command) → {CommandLoader}

Loads a single command
Source:
See:
Parameters:
Name Type Description
command Command | function Either a Command instance, or a constructor for one
Returns:
Type:
CommandLoader

loadCommands(commands) → {CommandLoader}

Loads multiple commands
Source:
Parameters:
Name Type Description
commands Array.<Command> | Array.<function()> An array of Command instances, or constructors
Returns:
Type:
CommandLoader

loadCommandsIn(options) → {CommandLoader}

Loads all commands in a directory. The files must export a Command class constructor or instance.
Source:
Parameters:
Name Type Description
options string | RequireAllOptions The path to the directory, or a require-all options object
Returns:
Type:
CommandLoader

loadDefaultCommands(optionsopt) → {CommandLoader}

Loads the default commands
Source:
Parameters:
Name Type Attributes Description
options Object <optional>
The object to specify which commands not to register
Name Type Attributes Default Description
eval_ boolean <optional>
true Whether or not to load the built-in `eval` command
exec boolean <optional>
true Whether or not to load the built-in `exec` command
help boolean <optional>
true Whether or not to load the built-in `help` command
ping boolean <optional>
true Whether or not to load the built-in `ping` command
stats boolean <optional>
true Whether or not to load the built-in `stats` command
Returns:
Type:
CommandLoader

resolveCommandPath(group, name) → {string}

Resolves a command file path from a command's group ID and memberName
Source:
Parameters:
Name Type Description
group string The command's group
name string Name of the command
Returns:
Type:
string
Fully-resolved path to the corresponding command file