Skip to content
Classcorev0.12.0

DispatchContext

State shared by middleware, gates, and handlers during one dispatch.

class DispatchContext<
    Kind extends DispatchKind = DispatchKind
> implements DispatchBag

Member visibility

Filter class members by access level.

constructor

Constructs a new instance of the DispatchContext class

DispatchContext(
    kind: Kind,
    route: string,
    fallback?: boolean
)

Showing members with Protected visibility and higher.

declaredRoute

The routeId of the handler's own route. It's null on an event and on the unhandled default.

public get declaredRoute(): string | null

fallback

True when this route doesn't have a registered handler.

public readonly fallback: boolean

kind

What started this dispatch, an interaction kind or event.

public readonly kind: Kind

route

The slash path, context menu name, custom-ID prefix, or event name that started this dispatch. For a custom ID that seedcord didn't make, it can be empty or a cut-off piece of that ID.

public readonly route: string

routeId

The dispatch identifier, such as slash:search/docs, button:approve, or event:messageCreate. Component identifiers contain the custom-ID prefix without encoded params.

public get routeId(): string

require()

Read a key that must be present, with undefined stripped from the result.

public require<Key>(
    key: Key
): Exclude<DispatchState[Key], undefined>

Throws:

A SeedcordError when nothing set the key on this dispatch.