Skip to main content

CommandManager

The main hub for creating and managing commands.

warning

You should never have to construct this class yourself.

import { client } from 'beapi-core';

client.commands.register(...);

Constructor​

new CommandManager(client);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
clientClient❌nullConstructed Client instance.

Methods​

createHandler​

Creates a new command handler allowing for a different prefix and more customizations.

createHandler(prefix);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
prefixstring❌undefinedPrefix new handler should use.

Returns​

CommandHandler


removeHandler​

Removes a custom handler.

removeHandler(prefix);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
prefixstring❌undefinedPrefix of handler.

Returns​

void


getHandler​

Gets a custom handler.

getHandler(prefix);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
prefixstring❌undefinedPrefix of handler.

Returns​

CommandHandler | undefined


setHandler​

Sets a custom handler.

setHandler(prefix, handler);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
prefixstring❌undefinedPrefix of handler.
handlerCommandHandler❌undefinedCommandHandler instance.

Returns​

void


register​

Register a command with the default handler.

register(options, cb);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
optionsCommandOptions❌undefinedOptions for command.
cbCommandCallback❌undefinedCallback function called on usage.

Returns​

void


unregister​

Unregister a command on the default handler.

unregister(name);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
namestring❌undefinedName of the command.

Returns​

void


get​

Gets a command on the default handler.

get(name);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
namestring❌undefinedName of the command.

Returns​

Command | undefined


getAll​

Gets all commands on the default handler.

getAll();

Returns​

Map<string, Command>


disable​

Disables default command handler (useful cause current one is temporary, whoops).

disable();

Returns​

void