Skip to content

ComponentHandler

Signature

export declare class ComponentHandler extends BaseHandler

Private 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

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 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

hasComponent(id: string, customId: string): boolean | undefined;
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>;