discord-bot-cli
Version:
An easy way to build a command-based discord bot with discord.js.
100 lines (99 loc) • 4.68 kB
TypeScript
import { Message, User, PermissionString, Guild, GuildMember } from "discord.js";
import { CommandSet } from "./CommandSet";
import { CommandSetOptions } from "./CommandSetOptions";
import { ArgDefinition } from "./definition/ArgDefinition";
import { FlagDefinition } from "./definition/FlagDefinition";
import { RestDefinition } from "./definition/RestDefinition";
import { ReadonlyCommandCollection } from "./CommandCollection";
import { Throttler } from "./Throttler";
export declare class Command {
/** Path to the file that contains the command if it's a top-most command, `null` otherwise. */
readonly filepath: string | null;
/** Name of this command. */
readonly name: string;
/** Aliases of this command. */
readonly aliases: readonly string[];
/** The list of permissions the bot's user require to execute this command. */
readonly clientPermissions: readonly PermissionString[];
/** The list of permissions the user require to execute this command. */
readonly userPermissions: readonly PermissionString[] | undefined;
/** The list of exemples for this command. */
readonly examples: readonly string[];
/** The description of the command. */
readonly description: string;
/** This command's parent or `null` if it's a top-most command. */
readonly parent: Command | null;
/** The [[CommandSet]] that contains this command. */
readonly commandSet: CommandSet;
/** A [[ReadonlyCommandCollection]] of this command's sub-commands. */
readonly subs: ReadonlyCommandCollection;
/** A `ReadonlyMap` with this command's arguments' [[ArgDefinition]] */
readonly args: ReadonlyMap<string, ArgDefinition>;
/** A [[RestDefinition]] if this command use the rest argument, `undefined` otherwise. */
readonly rest: Readonly<RestDefinition> | undefined;
/** A `ReadonlyMap` with this command's flags' [[FlagDefinition]] */
readonly flags: ReadonlyMap<string, FlagDefinition>;
private readonly _flagsShortcuts;
private readonly _executor;
private readonly _canUse;
private readonly _help;
private readonly _useThrottlerOnSubs;
/** Either or not this command is ignored. */
readonly ignored: boolean;
/** Either or not this command can only be used by dev (see [[CommandSetOptions.devIDs]]). */
readonly devOnly: boolean;
/** Either or not this command can only be used from a guild. */
readonly guildOnly: boolean;
/** Either or not the message that executed this command is deleted after the command execution. */
readonly deleteMessage: boolean;
private readonly _throttler;
/** Either or not this command's throttler also includes users with administrator permission. */
readonly _throttlingIncludeAdmins: boolean;
private constructor();
private static _build;
/**
* The [[Throttler]] used by this command.
*/
get throttler(): Throttler | undefined;
/**
* Either or not this command has an executor.
*/
get hasExecutor(): boolean;
/**
* Returns an array containing all parents of this command, ordered from top-most command to this command (included).
* @returns An array of this command's parent [[Command]].
*/
getParents(): Command[];
/**
* Determines if the bot's user have required permissions to execute this command from the guild.
* @param guild The guild from which check permissions.
* @returns Either or not the bot's user have required permissions to execute this command from the guild.
*/
hasClientPermissions(guild: Guild): boolean;
/**
* Determines if a member have required permissions to execute this command.
* @param member
* @returns Either or not the member have required permissions to execute this command.
*/
hasPermissions(member: GuildMember): boolean;
/**
* Call the `canUse` handler of this command and its parents (see [[CommandDefinition.canUse]])
* and return the first negative result (`false` or a `string`) or `true`.
* @param user
* @param message
* @returns Result of `canUse` handlers.
*/
canUse(user: User, message: Message): boolean | string;
/**
* Determines of the message author pass the [[canUse]] and the [[hasPermissions]] checks.
* @param message
* @returns Either or not the message author pass the [[canUse]] and the [[hasPermissions]] checks.
*/
checkPermissions(message: Message): boolean;
/**
* Call the suitable help handler for this command.
* @param message
* @param options
*/
help(message: Message, options: CommandSetOptions): Promise<void>;
}