UNPKG

829 BTypeScriptView Raw
1import type { EmitterWebhookEvent, EmitterWebhookEventName, HandlerFunction, Options, WebhookError, WebhookEventHandlerError } from "../types.js";
2export interface EventHandler<TTransformed> {
3 on<E extends EmitterWebhookEventName>(event: E | E[], callback: HandlerFunction<E, TTransformed>): void;
4 onAny(handler: (event: TTransformed extends unknown ? EmitterWebhookEvent : EmitterWebhookEvent & TTransformed) => any): void;
5 onError(handler: (event: WebhookEventHandlerError<TTransformed>) => any): void;
6 removeListener<E extends EmitterWebhookEventName>(event: E | E[], callback: HandlerFunction<E, TTransformed>): void;
7 receive(event: EmitterWebhookEvent | WebhookError): Promise<void>;
8}
9export declare function createEventHandler<TTransformed>(options: Options<TTransformed>): EventHandler<TTransformed>;