Skip to main content
Version: 1.x

RuntimePlugin

RuntimePlugin​

CommandKit plugin that runs at the runtime.

Signature
class RuntimePlugin<T extends PluginOptions = PluginOptions> extends PluginCommon<T, CommandKitPluginRuntime> {
public readonly type = PluginType.Runtime;
public readonly preload = new Set<string>();
onBeforeCommandsLoad(ctx: CommandKitPluginRuntime) => Promise<void>;
onAfterCommandsLoad(ctx: CommandKitPluginRuntime) => Promise<void>;
onBeforeEventsLoad(ctx: CommandKitPluginRuntime) => Promise<void>;
onAfterEventsLoad(ctx: CommandKitPluginRuntime) => Promise<void>;
onBeforeClientLogin(ctx: CommandKitPluginRuntime) => Promise<void>;
onAfterClientLogin(ctx: CommandKitPluginRuntime) => Promise<void>;
onBeforeInteraction(ctx: CommandKitPluginRuntime, interaction: Interaction) => Promise<void>;
onBeforeMessageCommand(ctx: CommandKitPluginRuntime, message: Message) => Promise<void>;
executeCommand(ctx: CommandKitPluginRuntime, env: CommandKitEnvironment, source: Interaction | Message, command: PreparedAppCommandExecution, execute: () => Promise<any>) => Promise<boolean>;
onEventsRouterInit(ctx: CommandKitPluginRuntime) => Promise<void>;
onCommandsRouterInit(ctx: CommandKitPluginRuntime) => Promise<void>;
performHMR(ctx: CommandKitPluginRuntime, event: CommandKitHMREvent) => Promise<void>;
prepareCommand(ctx: CommandKitPluginRuntime, commands: CommandBuilderLike) => Promise<CommandBuilderLike | null>;
onBeforeRegisterCommands(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>;
onBeforeRegisterGlobalCommands(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>;
onBeforePrepareGuildCommandsRegistration(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>;
onBeforeRegisterGuildCommands(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>;
onAfterCommand(ctx: CommandKitPluginRuntime, env: CommandKitEnvironment) => ;
willEmitEvent(ctx: CommandKitPluginRuntime, event: CommandKitEventDispatch) => ;
}

type​

property

preload​

property

onBeforeCommandsLoad​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called before commands are loaded

onAfterCommandsLoad​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called after commands are loaded

onBeforeEventsLoad​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called before events are loaded

onAfterEventsLoad​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called after events are loaded

onBeforeClientLogin​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called before the client logs in

onAfterClientLogin​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called after the client logs in

onBeforeInteraction​

method
(ctx: CommandKitPluginRuntime, interaction: Interaction) => Promise<void>

Called before interaction is handled

onBeforeMessageCommand​

method
(ctx: CommandKitPluginRuntime, message: Message) => Promise<void>

Called before message command is processed

executeCommand​

method
(ctx: CommandKitPluginRuntime, env: CommandKitEnvironment, source: Interaction | Message, command: PreparedAppCommandExecution, execute: () => Promise<any>) => Promise<boolean>

Called before command is executed. This method can execute the command itself.

onEventsRouterInit​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called after events router is initialized

onCommandsRouterInit​

method
(ctx: CommandKitPluginRuntime) => Promise<void>

Called after commands router is initialized

performHMR​

method
(ctx: CommandKitPluginRuntime, event: CommandKitHMREvent) => Promise<void>

Called when HMR event is received

prepareCommand​

method

Called before command is loaded for registration. This method can be used to modify the command data before it is loaded.

onBeforeRegisterCommands​

method
(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>

Called before command is registered to discord. This method can cancel the registration of the command and handle it manually.

onBeforeRegisterGlobalCommands​

method
(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>

Called before global commands registration. This method can cancel the registration of the command and handle it manually. This method is called after onBeforeRegisterCommands if that stage was not handled.

onBeforePrepareGuildCommandsRegistration​

method
(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>

Called before guild commands registration. This method can cancel the registration of the command and handle it manually. This method is called before guilds of the command are resolved. It is called after onBeforeRegisterCommands if that stage was not handled.

onBeforeRegisterGuildCommands​

method
(ctx: CommandKitPluginRuntime, event: PreRegisterCommandsEvent) => Promise<void>

Called before guild commands registration. This method can cancel the registration of the command and handle it manually. This method is called after guilds of the command are resolved. It is called after onBeforePrepareGuildCommandsRegistration if that stage was not handled.

onAfterCommand​

Called after command and all of its deferred functions are executed.

willEmitEvent​

Called before emitting an event