EventMiddleware
Base class for Discord event middleware.
Middleware runs before event handlers and can stop the event by throwing a Silence. Unlike EventHandler, it runs the SAME for every event it is registered for, so it has no match. Specify a single event in the generic and { events } to read this.event fully typed. Span several events (or omit { events } for a catchall) and this.event narrows to never, read this.eventName and do work that does not depend on the payload shape. A middleware that needs each event's payload is written one event per class.
abstract class EventMiddleware<
EventName extends ValidNonInteractionKeys = ValidNonInteractionKeys
> extends BaseHandler<ClientEvents[EventName]>Member visibility
Filter class members by access level.
EventMiddleware(
event: ClientEvents[EventName],
core: Core,
eventName?: EventName
)EventName
One or more ClientEvents keys. Defaults to every event (catchall).
EventName extends ValidNonInteractionKeys = ValidNonInteractionKeyscore
readonly core: TCoreInherited from:BaseHandler
- optional
dispatch
protected readonly dispatch: DispatchContext | undefinedInherited from:BaseHandler
protected readonly event: SingleEventPayload<EventName>protected eventName: EventNamelogger
protected readonly logger: LoggerInherited from:BaseHandler
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.
Inherited from:BaseHandler
getEvent()
getEvent(): ValidEventInherited from:BaseHandler