SlashHandler
Base class for a chat-input (slash) command handler.
Pass the route from the generated registry as the generic, the same string as @SlashRoute@SlashRoute, then read this.optionsthis.options for a single command or this.matchthis.match for several. Command authoring stays plain discord.js, seedcord codegenseedcord codegen reads its toJSON()toJSON() to type these options.
abstract class SlashHandler<
Route extends keyof SlashOptionRegistry,
Cache extends CacheType = "cached"
> extends InteractionHandler<ChatInputCommandInteraction<Cache>>abstract class SlashHandler<
Route extends keyof SlashOptionRegistry,
Cache extends CacheType = "cached"
> extends InteractionHandler<ChatInputCommandInteraction<Cache>>Member visibility
Filter class members by access level.
constructor
Constructs a new instance of the InteractionHandlerInteractionHandler class
Inherited from:InteractionHandler
Route
One or more route keys from SlashOptionRegistrySlashOptionRegistry, e.g. 'ban''ban' or 'ban' | 'kick''ban' | 'kick'.
Route extends keyof SlashOptionRegistryRoute extends keyof SlashOptionRegistryCache
The interaction cache state, 'cached''cached' by default.
core
Inherited from:BaseHandler
event
protected readonly event: ValidEventprotected readonly event: ValidEventInherited from:BaseHandler
logger
Inherited from:BaseHandler
The typed options for this command's route. Required options drop the null, choices narrow to their literal union, and only the getters for kinds this command actually uses appear. Use this.event.optionsthis.event.options directly for anything outside this view, such as narrowing a channel option by type.
protected options: SlashOptions<Route, Cache>protected options: SlashOptions<Route, Cache>execute()
Holds the main logic of your handler. The dispatcher calls it after the handler's gates pass, so a gate that refuses stops execute()execute() from running.
Inherited from:BaseHandler
Run the arm for whichever command fired. Use this only when the handler is registered for several routes. A single-route handler reads this.optionsthis.options directly instead, match buys nothing there.
Provide one arm per registered route, keyed by its route string, and each arm receives that route's own narrowed options. The arms must cover every route in the generic, a missing route or an unknown key is a compile error.
protected async match<Ret>(
arms: SlashMatchArms<Route, Cache, Ret>
): Promise<Ret>protected async match<Ret>(
arms: SlashMatchArms<Route, Cache, Ret>
): Promise<Ret>armsOne handler per registered route, keyed by route string.