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
InteractionHandler(
event: Repliable,
core: Core,
dispatch?: DispatchContext
)InteractionHandler(
event: Repliable,
core: Core,
dispatch?: DispatchContext
)Inherited from:InteractionHandler
Showing members with Protected visibility and higher.
Properties
Methods
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.
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>buildSender()
protected buildSender(
event: Event,
_core: Core,
routeId: string
): ReplySenderprotected buildSender(
event: Event,
_core: Core,
routeId: string
): ReplySenderInherited from:RepliableHandler
Run the arm for whichever command fired. Use this only when the handler is registered for several routes.
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.
showModal()
Open a modal. Must be the initial response to this interaction. The modal kind rejects this call at compile time (Discord forbids a modal in response to a modal).
protected async showModal(
this: InteractionHandler<NonModalInteraction>,
modal: ModalLike
): Promise<void>protected async showModal(
this: InteractionHandler<NonModalInteraction>,
modal: ModalLike
): Promise<void>Inherited from:InteractionHandler