CommandKit
CommandKit
The commandkit class that serves as the main entry point for the CommandKit framework.
class CommandKit extends EventEmitter {
public eventInterceptor!: EventInterceptor;
public static readonly createElement = createElement;
public static readonly Fragment = Fragment;
public readonly config: CommandKitConfiguration = {
defaultLocale: Locale.EnglishUS,
getMessageCommandPrefix: () => '!',
};
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[]>) => ;
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
The static createElement function to create jsx elements
Fragment
The static Fragment component to create jsx fragments
config
The configuration for the CommandKit instance.
store
A key-value store for storing arbitrary data.
flags
A flag store for storing flags that can be used to enable or disable features.
commandsRouter
The command router for the CommandKit instance.
eventsRouter
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
CommandKit | undefined
The static instance of CommandKit.
constructor
(options: CommandKitOptions = {}) => CommandKit
Create a new command and event handler with CommandKit.
start
(token?: string | false) =>
Starts the commandkit application.
loadPlugins
() =>
Loads all the plugins.
started
Whether or not the commandkit application has started.
setPrefixResolver
(resolver: (message: Message) => Awaitable<string | string[]>) =>
Sets the prefix resolver for the command handler.
setDefaultLocale
(locale: Locale) =>
Sets the default locale for the command handler.
client
Client
Get the client attached to this CommandKit instance.
setClient
(client: Client) =>
Sets the client attached to this CommandKit instance.
reloadCommands
() =>
Updates application commands with the latest from "commandsPath".
reloadEvents
() =>
Updates application events with the latest from "eventsPath".
incrementClientListenersCount
() =>
Increment the client listeners count.
decrementClientListenersCount
() =>
Decrement the client listeners count.
getAppDirectory
() =>
Path to the app directory. Returns null
if not found.
The lookup order is:
./app
./src/app
getPath
(to: 'commands' | 'events') =>
Get the path to the commands or events directory.