Class: CommandManager
Command manager for client
Constructors
Constructor
new CommandManager(
client):CommandManager
Creates a new command manager
Parameters
client
Client instance
Returns
CommandManager
Methods
[kHandleCommand]()
[kHandleCommand](
message,enhanceMessage):Promise<void>
Internal
Main method for handling commands
Parameters
message
Message object
enhanceMessage
(msg) => void
Function to enhance message
Returns
Promise<void>
addAlias()
addAlias(
alias,command):void
Adds alias for command
Parameters
alias
string
Command alias
command
string
Original command
Returns
void
Example
client.commands.addAlias('h', 'help');
// Now both 'help' and 'h' will execute the same commandget()
get(
command):undefined| {argsSchema:CommandArgsSchema;description?:string; }
Returns command information
Parameters
command
string
Command name
Returns
undefined | { argsSchema: CommandArgsSchema; description?: string; }
Object with command information or undefined if command not found
Example
const cmdInfo = client.commands.get('help');
if (cmdInfo) {
console.log('Command args schema:', cmdInfo.argsSchema);
}getAll()
getAll():
string[]
Returns list of registered commands
Returns
string[]
Array of command names
Example
const commands = client.commands.getAll();
console.log('Registered commands:', commands);
// Result: Registered commands: [ 'info', 'help' ]register()
register(
command,argsSchema,handler):void
Registers a new command
Parameters
command
string
Command name
argsSchema
Command arguments schema
handler
Command handler
Returns
void
Examples
client.commands.register('hello', { name: 'string' }, (message, args) => {
console.log(`Hello, ${args.name}!`);
});client.commands.register('add', { a: 'int', b: 'int' }, (message, args) => {
const sum = args.a + args.b;
message.reply(`The sum is ${sum}`);
});remove()
remove(
command):boolean
Removes command
Parameters
command
string
Command name
Returns
boolean
true if command was removed, false otherwise
Example
const removed = client.commands.remove('help');
console.log('Command removed:', removed); // true or false