cumsystem
Version:
simple command system and command handler
73 lines (72 loc) • 2.5 kB
TypeScript
/// <reference types="node" />
import * as Discord from 'discord.js';
import { Command } from './Command';
import { EventEmitter } from 'events';
/**
* Represents the commands and options of a single bot
*/
export declare class System extends EventEmitter {
/** The prefix used for detecting commands */
prefix: string;
/** The client of the command system */
client: Discord.Client;
/** An array of commands */
commands: Command[];
/** The client application of the client, only used to get the owner ID */
application: Discord.ClientApplication | undefined;
/** The ID of the bot owner */
ownerID: string | undefined;
private setValues;
/**
* Makes a new command system with no commands except the default commands (ping, help)
* @example
* ```typescript
* const Discord = require('discord.js');
* const CommandSystem = require('cumsystem');
*
* const client = new Discord.Client();
* const cs = new CommandSystem.System(client, '!');
* ```
* @param {Discord.Client} client The client of the command system
* @param {string} prefix The prefix to use for command detection
*/
constructor(client: Discord.Client, prefix: string);
/**
* Add a command to the commands list
* @example
* ```typescript
* cs.addCommand(new CommandSystem.SimpleCommand('hi', () => {
* return 'hello!';
* }));
* ```
* @param {Command} command The command itself
*/
addCommand(command: Command): void;
/**
* Sets a client for the command system to use
* @param {Discord.Client} clientSet The client
*/
setClient(clientSet: Discord.Client): void;
/**
* Sets a prefix for the command system to use
* @param {string} prefixSet The prefix
*/
setPrefix(prefixSet: string): void;
/**
* Set a key to a value in the system (useful for passing values through modules without directly passing them to the function)
* @param {string} key
* @param {any} value
*/
set(key: string, value: any): any;
/**
* Get a value from a key in the system
* @param {string} key
*/
get(key: string): any;
/**
* Parses messages, recommended to put in your client message listener
* @param {Discord.Message} message The message
* @param {string} prefixOverride A prefix override to use instead of the default one, useful for custom prefixes
*/
parseMessage(message: Discord.Message, prefixOverride?: string): void;
}