CommandHandler
Signature
export declare class CommandHandler extends BaseHandlerProperties
8Methods
25Properties
protected logger: Logger;protected client: UsingClient;values: (Command | ContextMenuCommand)[];entryPoint: EntryPointCommand | null;filter: (path: string) => boolean;Filters a file path.
path- The path to filter.
`true` if the path passes the filter, otherwise `false`.
private reloadFile;Reloads a command file the way `load()` reads it, through `onFile`, so a file can export several commands. Every command from the file is replaced, in place, by what it exports now, with the plugin load options applied to each; a transform returning `false` still removes its command. A file that fails to import or exports no command keeps its previous commands. As before this method existed, an `@AutoLoad` command's directory is not scanned again, so the reloaded command comes back without its auto-loaded subcommands.
private prepareCommand;private normalizeLoadOptions;Methods
constructorConstructorconstructor(logger: Logger, client: UsingClient);reload(resolve: string | Command): Promise<Command | ContextMenuCommand | EntryPointCommand | null>;reloadFiles(stopIfFail?: boolean): Promise<HandlerReloadResult>;Reloads every loaded command file and reports which files reloaded and which failed or exported nothing. Failed files keep their previous commands. 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>;protected shouldUploadLocales(locales?: LocalizationMap | null, cachedLocales?: LocalizationMap | null): boolean;protected shouldUploadChoices(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean;protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean;shouldUpload(file: string, guildId?: string): Promise<boolean>;checkSubCommandsLimit(command: Command): void;set(commands: SeteableCommand[], optionsOrTransform?: CommandLoadTransformer | CommandLoadOptions): (Command | ContextMenuCommand | EntryPointCommand)[];load(commandsDir: string, client: UsingClient, options?: CommandLoadOptions): Promise<(Command | ContextMenuCommand)[]>;parseLocales(command: InstanceType<HandleableCommand>): Command | ContextMenuCommand | EntryPointCommand | SubCommand;protected getLocales(locale: string): ("bg" | "cs" | "da" | "de" | "el" | "en-GB" | "en-US" | "es-419" | "es-ES" | "fi" | "fr" | "hi" | "hr" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "nl" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "sv-SE" | "th" | "tr" | "uk" | "vi" | "zh-CN" | "zh-TW")[];protected getLocaleKey(locale: string, key: string, context: string): string | undefined;parseGlobalLocales(command: InstanceType<HandleableCommand>): void;parseCommandOptionLocales(option: CommandOption, commandName?: string): void;parseCommandLocales(command: Command): void;parseContextMenuLocales(command: ContextMenuCommand): ContextMenuCommand;parseSubCommandLocales(command: SubCommand): SubCommand;stablishContextCommandDefaults(commandInstance: InstanceType<HandleableCommand>): ContextMenuCommand | false;stablishCommandDefaults(commandInstance: InstanceType<HandleableCommand>): OmitInsert<Command, 'options', { options: NonNullable<Command['options']>;}> | false;stablishSubCommandDefaults(commandInstance: Command, option: SubCommand): SubCommand;onFile(file: FileLoaded): HandleableCommand[] | undefined;onCommand(file: SeteableCommand, create?: CommandLoadCreator): HandleableCommandInstance | false;onSubCommand(file: HandleableSubCommand): SubCommand | false;