import type { ComponentCallback, ComponentOnErrorCallback, ListenerOptions, ModalSubmitCallback } from '../builders/types'; import { LimitedCollection } from '../collection'; import { type UsingClient } from '../commands'; import type { FileLoaded } from '../commands/handler'; import { BaseHandler, type Logger, type OnFailCallback } from '../common'; import type { ComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from '../structures'; import { ComponentCommand } from './componentcommand'; import type { ComponentContext } from './componentcontext'; import { ModalCommand } from './modalcommand'; import type { ModalContext } from './modalcontext'; type ComponentSetTransformer = (component: ComponentCommands) => ComponentCommands | false | void; type UserMatches = string | string[] | RegExp; type COMPONENTS = { components: { match: MatchCallback; callback: ComponentCallback; }[]; options?: ListenerOptions; messageId: string; channelId: string; guildId: string | undefined; idle?: NodeJS.Timeout; timeout?: NodeJS.Timeout; onError?: ComponentOnErrorCallback; __run: (customId: UserMatches, callback: ComponentCallback) => any; }; export type MatchCallback = (str: string) => boolean; export type CollectorInteraction = ComponentInteraction | StringSelectMenuInteraction; export type ComponentCommands = ComponentCommand | ModalCommand; export interface CreateComponentCollectorResult { run(customId: UserMatches, callback: ComponentCallback): void; stop(reason?: string): void; waitFor(customId: UserMatches, timeout?: number): Promise; resetTimeouts(): void; } export declare class ComponentHandler extends BaseHandler { protected client: UsingClient; onFail: OnFailCallback; readonly values: Map; readonly modals: LimitedCollection; readonly commands: ComponentCommands[]; filter: (path: string) => boolean; constructor(logger: Logger, client: UsingClient); private createMatchCallback; createComponentCollector(messageId: string, channelId: string, guildId: string | undefined, options?: ListenerOptions, components?: COMPONENTS['components']): CreateComponentCollectorResult; onComponent(id: string, interaction: ComponentInteraction): Promise; hasComponent(id: string, customId: string): boolean | undefined; resetTimeouts(id: string): void; hasModal(interaction: ModalSubmitInteraction): boolean; onModalSubmit(interaction: ModalSubmitInteraction): any; deleteValue(id: string, reason?: string): void; clearValue(id: string): COMPONENTS | undefined; establishDefaults(component: ComponentCommands): void; private normalizeLoadOptions; private materializeComponent; set(instances: SeteableComponentCommand[], optionsOrTransform?: ComponentSetTransformer | ComponentLoadOptions): ComponentCommands[]; load(componentsDir: string, options?: ComponentLoadOptions): Promise; reload(path: string): Promise; reloadAll(stopIfFail?: boolean): Promise; execute(i: ComponentCommands, context: ComponentContext | ModalContext): Promise; executeComponent(context: ComponentContext): Promise; executeModal(context: ModalContext): Promise; onFile(file: FileLoaded): HandleableComponentCommand[] | undefined; callback(file: SeteableComponentCommand, create?: ComponentLoadCreator): ComponentCommands | false; } export type HandleableComponentCommand = (new () => ComponentCommand) | (new () => ModalCommand); export type SeteableComponentCommand = HandleableComponentCommand | ComponentCommands; export type ComponentLoadKind = 'component' | 'modal'; export type ComponentLoadCreator = (kind: ComponentLoadKind, constructor: T, next: () => InstanceType) => InstanceType; export type ComponentLoadTransformer = (kind: ComponentLoadKind, component: ComponentCommands) => ComponentCommands | false | void; export interface ComponentLoadOptions { create?: ComponentLoadCreator; transform?: ComponentLoadTransformer; } export {};