import { PermissionResolvable, Message, MessageOptions } from 'discord.js'; import { Client } from '../client/Client'; import { MiddlewareFunction } from '../types/MiddlewareFunction'; import { CommandInfo } from '../types/CommandInfo'; import { RateLimiter } from './RateLimiter'; import { ArgOpts } from '../types/ArgOpts'; /** * Command class to extend to create commands users can execute * @param {CommandInfo} info - Object containing required command properties */ export declare class Command { private _disabled; client: T; name: string; desc: string; usage: string; info: string; group: string; aliases: string[]; guildOnly: boolean; hidden: boolean; argOpts: ArgOpts; callerPermissions: PermissionResolvable[]; clientPermissions: PermissionResolvable[]; roles: string[]; ownerOnly: boolean; overloads: string; external: boolean; _classloc: string; readonly _rateLimiter: RateLimiter; readonly _middleware: MiddlewareFunction[]; constructor(info?: CommandInfo); /** * Can be included in a command to initlialize any resources a command * needs at runtime that require things that are not available within * a command's constructor like the client instance or client/guild storages. * * Will be called after all commands are loaded (including those from * any loaded plugins) and after all base framework storages (client and guild) * are ready for use. * * >**Note:** Can be async if needed * @returns {Promise} */ init(): void; /** * Action to be executed when the command is called. The following parameters * are what command actions will be passed by the {@link CommandDispatcher} whenever * a command is called. Be sure to receive these in proper order when writing * new commands * @param {external:Message} message Discord.js message object * @param {any[]} args An array containing the args parsed from the command calling message.
* Will contain strings unless middleware is used to transform the args * @returns {any} */ action(message: Message, args: any[]): void; /** * Make necessary asserts for Command validity. * Called internally by the command loader * @private */ _register(client: T): void; /** * Whether or not this command is disabled * @type {boolean} */ readonly disabled: boolean; /** * Enable this command if it is disabled * @returns {void} */ enable(): void; /** * Disable this command if it is enabled * @returns {void} */ disable(): void; /** * Adds a middleware function to be used when the command is called * to make modifications to args, determine if the command can * be run, or anything else you want to do whenever this command * is called. * * See {@link MiddlewareFunction} for information on how a middleware * function should be represented * * Usage example: * ``` * .use((message, args) => [message, args.map(a => a.toUpperCase())]); * ``` * This will add a middleware function to this command that will attempt * to transform all args to uppercase. This will of course fail if any * of the args are not a string. * * >**Note:** Middleware functions should only be added to a command one * time each and thus should not be added within any sort of event or loop. * Multiple separate middleware functions can be added to the via multiple * separate calls to this method * @param {MiddlewareFunction} func The middleware function to use * @returns {Command} */ use(func: MiddlewareFunction): this; /** * Send provided response to the provided message's channel * via edit or send, depending on whether or not the client is * a selfbot * @protected * @param {external:Message} message Discord.js Message object * @param {string} response String to send * @param {external:MessageOptions} [options] Optional Discord.js MessageOptions * @returns {Promise} */ protected respond(message: Message, response: string, options?: MessageOptions): Promise; /** * Validate PermissionResolvables in the given array, throwing an error * for any that are invalid * @private */ private _validatePermissions(field, perms); }