Skip to content
Classcorev0.10.0

RepliableHandler

Shared base the repliable handlers on both transports extend. Defines the reply members over one sender. A handler builds its own through buildSender. A middleware takes the handler's.

abstract class RepliableHandler<
    Event,
    TCore extends CoreBase,
    TMessage extends { id: string },
    TNative,
    TSender extends BaseReplySender<TMessage, TNative>
> extends BaseHandler<Event, TCore>

Member visibility

Filter class members by access level.

constructor

Constructs a new instance of the RepliableHandler class

protected RepliableHandler(
    event: Event,
    core: TCore,
    dispatch: DispatchContext,
    sender?: TSender
)

Showing members with Protected visibility and higher.

Event

The repliable interaction type this handler processes

Event

TCore

The transport's Core

TCore extends CoreBase

TMessage

The transport's created-message lens

TMessage extends { id: string; }

TNative

The transport's own file forms, beyond the portable ReplyFile

TNative

TSender

The transport's reply sender

TSender extends BaseReplySender<TMessage, TNative>

dispatch

The bag for this dispatch. Each interaction gets its own. Every handler for one event shares a single bag.

protected readonly dispatch: DispatchContext

Inherited from:BaseHandler

event

protected readonly event: Event

Inherited from:BaseHandler

routeId

protected readonly routeId: string

sender

The reply surface for this interaction. Pass the handler to reply from outside its class.

public readonly sender: TSender

buildSender()

protected abstract buildSender(
    event: Event,
    core: TCore,
    dispatch: DispatchContext
): TSender

defer()

Show a "thinking" placeholder, then fill it later with edit.

protected async defer(opts?: DeferOpts): Promise<void>

delete()

Delete the initial reply or deferred placeholder. Pass a target to delete a message a prior send returned.

protected async delete(target?: TMessage): Promise<void>

edit()

Rewrite the initial reply or deferred placeholder. The targeted form rewrites a message a prior send returned.

protected async edit(
    response: ReplyResponse<TNative> | string
): Promise<TMessage>

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() from running.

abstract execute(): Promise<void>

Inherited from:BaseHandler

followUp()

Send a new message once the interaction is acknowledged.

protected async followUp(
    response: ReplyResponse<TNative> | string,
    opts?: SendOpts
): Promise<TMessage>

send()

Routes to reply, followUp, or edit based on the current ack state.

protected async send(
    response: ReplyResponse<TNative> | string,
    opts?: SendOpts
): Promise<TMessage>