Skip to main content
Version: 1.x

CommandKit

CommandKit​

The commandkit class that serves as the main entry point for the CommandKit framework.

Signature
class CommandKit extends EventEmitter {
public eventInterceptor!: EventInterceptor;
public static readonly createElement = createElement;
public static readonly Fragment = Fragment;
public readonly appConfig: CommandKitConfiguration = {
defaultLocale: Locale.EnglishUS,
getMessageCommandPrefix: () => '!',
};
public config: ResolvedCommandKitConfig = getConfig();
public readonly store = new Map<string, any>();
public readonly flags = new FlagStore();
public commandsRouter!: CommandsRouter;
public eventsRouter!: EventsRouter;
public commandHandler!: AppCommandHandler;
public eventHandler!: AppEventsHandler;
public plugins!: CommandKitPluginRuntime;
public events!: CommandKitEventsChannel;
public analytics!: AnalyticsEngine;
static instance: CommandKit | undefined = undefined;
constructor(options: CommandKitOptions = {})
start(token?: string | false) => ;
loadPlugins() => ;
started: void
setPrefixResolver(resolver: (message: Message) => Awaitable<string | string[] | RegExp>) => ;
setDefaultLocale(locale: Locale) => ;
client: Client
setClient(client: Client) => ;
reloadCommands() => ;
reloadEvents() => ;
incrementClientListenersCount() => ;
decrementClientListenersCount() => ;
getAppDirectory() => ;
getPath(to: 'commands' | 'events') => ;
}
  • Extends: EventEmitter

eventInterceptor​

The event interceptor to quickly register temporary event listeners

createElement​

property

The static createElement function to create jsx elements

Fragment​

property

The static Fragment component to create jsx fragments

appConfig​

The configuration for the CommandKit instance.

config​

The configuration for the CommandKit environment.

store​

property

A key-value store for storing arbitrary data.

flags​

property

A flag store for storing flags that can be used to enable or disable features.

commandsRouter​

The command router for the CommandKit instance.

eventsRouter​

property

The events router for the CommandKit instance.

commandHandler​

The command handler for the CommandKit instance. This is responsible for handling commands and their execution.

eventHandler​

The event handler for the CommandKit instance. This is responsible for handling events and their execution.

plugins​

The plugins runtime for the CommandKit instance.

events​

The events channel for the CommandKit instance. This can be used to emit custom events.

analytics​

The analytics engine for the CommandKit instance. This is responsible for tracking events and user interactions.

instance​

property
CommandKit | undefined

The static instance of CommandKit.

constructor​

method
(options: CommandKitOptions = {}) => CommandKit

Create a new command and event handler with CommandKit.

start​

method
(token?: string | false) =>

Starts the commandkit application.

loadPlugins​

method
() =>

Loads all the plugins.

started​

property

Whether or not the commandkit application has started.

setPrefixResolver​

method
(resolver: (message: Message) => Awaitable<string | string[] | RegExp>) =>

Sets the prefix resolver for the command handler.

setDefaultLocale​

method
(locale: Locale) =>

Sets the default locale for the command handler.

client​

property
Client

Get the client attached to this CommandKit instance.

setClient​

method
(client: Client) =>

Sets the client attached to this CommandKit instance.

reloadCommands​

method
() =>

Updates application commands with the latest from "commandsPath".

reloadEvents​

method
() =>

Updates application events with the latest from "eventsPath".

incrementClientListenersCount​

method
() =>

Increment the client listeners count.

decrementClientListenersCount​

method
() =>

Decrement the client listeners count.

getAppDirectory​

method
() =>

Path to the app directory. Returns null if not found. The lookup order is:

  • ./app
  • ./src/app

getPath​

method
(to: 'commands' | 'events') =>

Get the path to the commands or events directory.