UNPKG

@lilybird/handlers

Version:
39 lines 1.85 kB
import { ComponentType } from "lilybird"; import type { Awaitable, Client, Interaction } from "lilybird"; import type { HandlerListener } from "./shared.js"; import type { Interaction as TransformedInteraction, Message as TransformedMessage, MessageComponentData } from "@lilybird/transformers"; interface CompiledComponent { body: string; handler: [name: string, fn: MessageComponentHandler]; matcher?: [name: string, fn: MessageComponentHandler]; } export type MessageComponentHandler = (interaction: TransformedInteraction<MessageComponentData, TransformedMessage>) => Awaitable<unknown>; export interface ComponentStructure { type: Exclude<ComponentType, ComponentType.ActionRow>; id: string; customMatcher?: string | MessageComponentHandler; handle: MessageComponentHandler; } export interface DynamicComponentStructure { filter: (interaction: TransformedInteraction<MessageComponentData, TransformedMessage>) => Awaitable<boolean>; handle: MessageComponentHandler; timeout?: number; } export declare class MessageComponentStore { #private; constructor(handlerListener?: HandlerListener, attachDynamicComponentListener?: boolean); addDynamicComponent(component: DynamicComponentStructure): void; storeComponent(component: ComponentStructure): void; getCompilationStack(): { functionNames: IterableIterator<string>; handlers: IterableIterator<(...args: any) => any>; stack: string; } | null; compile(): ((client: Client, interaction: Interaction.Structure) => Awaitable<unknown>) | null; getStoredComponents(): Record<ComponentType, Array<CompiledComponent>>; clear(): void; set attachDynamicComponentListener(bool: boolean); get attachDynamicComponentListener(): boolean; } export {}; //# sourceMappingURL=message-component-store.d.ts.map