import { TeamSpeakClient } from "ts3-nodejs-library"; import { Commander } from "../Commander"; import { CommanderTextMessage, TranslationString } from "../util/types"; import { Throttle } from "../util/Throttle"; export declare type permissionHandler = (invoker: TeamSpeakClient) => Promise | boolean; export declare type runHandler = (event: CommanderTextMessage) => (Promise | void); export declare abstract class BaseCommand { protected commander: Commander; protected permissionHandler: permissionHandler[]; protected runHandler: runHandler[]; private cmdPrefix; private cmdHelp; private cmdManual; private cmdName; private cmdEnabled; private cmdThrottle; constructor(cmd: string, commander: Commander); abstract getUsage(): string; abstract hasPermission(client: TeamSpeakClient): Promise; abstract validate(args: string): Record; abstract handleRequest(args: string, ev: CommanderTextMessage): Promise; /** checks if the command is enabled */ isEnabled(): boolean; enable(): this; disable(): this; /** gets the command name without its prefix */ getCommandName(): TranslationString<{}>; /** gets the command name with its prefix */ getFullCommandName(): string; /** retrieves the help text */ getHelp(client: TeamSpeakClient): string; /** * sets a help text (should be a very brief description) * @param text help text */ help(text: TranslationString): this; /** returns a boolean wether a help text has been set or not */ hasHelp(): boolean; /** retrieves the current manual text */ getManual(client: TeamSpeakClient): string; /** returns a boolean wether a help text has been set or not */ hasManual(): boolean; /** * sets a prefix for this command * should only used in specific cases * by default the prefix gets inherited from its Commander * @param prefix the new prefix for this command */ prefix(prefix: string): this; /** gets the current prefix for this command */ getPrefix(): string; /** * sets a manual text, this function can be called multiple times * in order to create a multilined manual text * @param text the manual text */ manual(text: TranslationString): this; /** * clears the current manual text */ clearManual(): this; /** * register an execution handler for this command * @param callback gets called whenever the command should do something */ run(callback: runHandler): this; /** * adds an instance of a throttle class * @param throttle adds the throttle instance */ addThrottle(throttle: Throttle): this; private handleThrottle; /** * register a permission handler for this command * @param callback gets called whenever the permission for a client gets checked */ checkPermission(callback: permissionHandler): this; protected permCheck(client: TeamSpeakClient): Promise; protected dispatchCommand(ev: CommanderTextMessage): Promise; }