ComponentHandler
Signature
export declare class ComponentHandler extends BaseHandlerPrivate types
COMPONENTSTypeAlias
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;};ComponentSetTransformerTypeAlias
type ComponentSetTransformer = (component: ComponentCommands) => ComponentCommands | false | void;UserMatchesTypeAlias
type UserMatches = string | string[] | RegExp;Properties
11Methods
20Properties
protected client: UsingClient;onFail: OnFailCallback;readonly values: Map<string, COMPONENTS>;readonly modals: LimitedCollection<string, ModalSubmitCallback>;readonly commands: ComponentCommands[];filter: (path: string) => boolean;Filters a file path.
Parameters
path- The path to filter.
Returns
`true` if the path passes the filter, otherwise `false`.
private createMatchCallback;private normalizeLoadOptions;private materializeComponent;private prepareComponent;private reloadFile;Reloads a component file the way `load()` reads it, through `onFile`, so a file can export several components. Every entry from the file is replaced, in place, by what it exports now. A file that fails to import or exports nothing loadable keeps its previous entries.
Methods
constructorConstructorconstructor(logger: Logger, client: UsingClient);createComponentCollector(messageId: string, channelId: string, guildId: string | undefined, options?: ListenerOptions, components?: COMPONENTS['components']): CreateComponentCollectorResult;onComponent(id: string, interaction: ComponentInteraction): Promise<any>;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;set(instances: SeteableComponentCommand[], optionsOrTransform?: ComponentSetTransformer | ComponentLoadOptions): ComponentCommands[];load(componentsDir: string, options?: ComponentLoadOptions): Promise<void>;reload(path: string): Promise<any>;reloadFiles(stopIfFail?: boolean): Promise<HandlerReloadResult>;Reloads every loaded component file and reports which files reloaded and which failed or exported nothing. Failed files keep their previous components. With `stopIfFail`, it stops at the first failed file and throws a `RELOAD_FAILED` error carrying the report instead of returning it.
reloadAll(stopIfFail?: boolean): Promise<void>;execute(i: ComponentCommands, context: ComponentContext | ModalContext): Promise<any>;executeComponent(context: ComponentContext): Promise<void>;executeModal(context: ModalContext): Promise<void>;onFile(file: FileLoaded<HandleableComponentCommand>): HandleableComponentCommand[] | undefined;callback(file: SeteableComponentCommand, create?: ComponentLoadCreator): ComponentCommands | false;