Skip to content

Pipeline

Utility functions for the command dispatch pipeline - error responses, guards, permissionission checks, option transforms, middleware, and post-execute hooks.

Pipeline . sendErrorResponse ( interaction errorMessage override )  -> ()

Sends a generic error reply to the interaction, or delegates to override if provided.

Parameters

interaction: Modal
errorMessage: string
override: Modal, string) -> ())?
Pipeline . runGuards ( guardEntries interaction log name onGuardFailed onError )  -> boolean

Evaluates all guard entries against the interaction. AND guards must all pass; within an OR group at least one must pass. Returns false and fires the guard-failed handler on first failure.

Parameters

guardEntries: GuardEntry }
interaction: TypesCommand
log: Logger
name: string
onGuardFailed: TypesCommand) -> ())?
onError: Modal, string) -> ())?

Returns

boolean
Pipeline . getMissingPermissions ( permissionObject required )  -> { Permissions }

Returns permissionissions from required that are absent from permissionObject.

Parameters

permissionObject: Permission
required: Permissions }

Returns

Permissions }
Pipeline . runTransforms ( transforms interaction log name onError )  -> { [string]: any }?

Runs each named transform over its option value. Returns nil and fires the error handler if any transform throws; otherwise returns the full map of transformed values.

Parameters

transforms: {
{ [string]: command.TransformFunction } }
interaction: TypesCommand
log: Logger
name: string
onError: Modal, string) -> ())?

Returns

{
{ [string]: any } }
Pipeline . injectGetTransformed ( interaction transformed )  -> ()

Injects a getTransformed(name) method onto the interaction for retrieving transformed option values.

Parameters

interaction: TypesCommand
transformed: {
{ [string]: any } }
Pipeline . runAfterHooks ( afterHooks perCommand interaction log )  -> ()

Runs the per-command afterExecute hook followed by all global after-hooks. Errors in individual hooks are logged but do not propagate.

Parameters

afterHooks: TypesCommand) -> () }
perCommand: TypesCommand) -> ())?
interaction: TypesCommand
log: Logger
Pipeline . runMiddleware ( middlewares index interaction final log )  -> ()

Recursively runs each middleware in order, calling final when the chain is exhausted.

Parameters

middlewares: { (any, () -> ()) -> () }
index: number
interaction: any
final: () -> ()
log: Logger