sheweny
Version:
The powerful framework for create discord bots
145 lines (144 loc) • 4.66 kB
TypeScript
import { BaseStructure } from './index.js';
import { ShewenyError } from '../helpers/index.js';
import { COMMAND_CHANNEL } from '../constants/constants.js';
import type { ShewenyClient } from '../client/Client.js';
import type { MessageCommandOptionData, CommandMessageArgsResolved, CommandData, CommandType, Awaitable } from '../typescript/index.js';
import type { ApplicationCommandOptionData, CommandInteraction, ContextMenuCommandInteraction, Message, AutocompleteInteraction, PermissionResolvable, LocalizationMap } from 'discord.js';
/**
* Represents an Command structure
* @extends {BaseStructure}
*/
export declare abstract class Command extends BaseStructure {
/**
* If a command is reserved for bot admins
* @type {boolean}
*/
adminsOnly: boolean;
/**
* Register Slash Command or not
* @type {boolean}
*/
registerApplicationCommand: boolean;
/**
* Aliases of the Message command
* @type {string[] | undefined}
*/
aliases?: string[];
/**
* Args of a Message command
* @type {MessageCommandOptionData | undefined}
*/
args?: MessageCommandOptionData[];
/**
* Category of a command
* @type {string}
*/
category: string;
/**
* Only channel where a command can be executed
* @type {"GUILD" | "DM" | undefined}
*/
channel?: typeof COMMAND_CHANNEL.dm | typeof COMMAND_CHANNEL.global | typeof COMMAND_CHANNEL.guild;
/**
* The permissions required for the client
* @type {PermissionResolvable[]}
*/
clientPermissions: PermissionResolvable[];
/**
* Cooldown of a command in seconds
* @type {number}
*/
cooldown: number;
/**
* Description of a command
* @type {string | undefined}
*/
description: string;
/**
* Localized descriptions of the command
* @type {LocalizationMap}
*/
descriptionLocalizations?: LocalizationMap;
/**
* Examples of a command
* @type {string}
*/
examples?: string | string[];
/**
* Name of a command
* @type {string}
*/
name: string;
/**
* Localized names of the command
* @type {LocalizationMap}
*/
nameLocalizations?: LocalizationMap;
/**
* Options of a Application command
* @type {ApplicationCommandOptionData[] | undefined}
*/
options?: ApplicationCommandOptionData[];
/**
* Type of a command
* @type {CommandType}
*/
type: CommandType;
/**
* Usage of a command
* @type {string | string[] | undefined}
*/
usage?: string | string[];
/**
* The permissions required to be executed by the user
* @type {PermissionResolvable[]}
*/
userPermissions: PermissionResolvable[];
/**
* Constructor for build a Command
* @param {ShewenyClient} client Client framework
* @param {CommandData} data Data for build a Command
*/
constructor(client: ShewenyClient, data: CommandData);
/**
* This function is executed before executing the `execute` function
* @param {CommandInteraction | ContextMenuCommandInteraction | Message} interaction Interaction
* @returns {any | Promise<any>}
*/
before?(interaction: CommandInteraction | ContextMenuCommandInteraction | Message): Awaitable<unknown>;
/**
* Main function `execute` for the commands
* @param {CommandInteraction | ContextMenuCommandInteraction | Message} interaction Interaction
* @param {CommandMessageArgsResolved[]} [args] Arguments of the Message command
* @returns {any | Promise<any>}
*/
abstract execute(interaction: CommandInteraction | ContextMenuCommandInteraction | Message, args?: CommandMessageArgsResolved[]): Awaitable<unknown>;
/**
* Check the type of a command
* @param type - Type of a command
* @param types - Types allowed
* @returns {boolean}
*/
private isType;
/**
*
* @param {AutocompleteInteraction} interaction
* @returns {any | Promise<any>}
*/
onAutocomplete?(interaction: AutocompleteInteraction): Awaitable<unknown>;
/**
* Register a command in collections
* @returns {Collection<string, ApplicationCommand>} The Application Commands collection
*/
register(): Promise<Command | ShewenyError>;
/**
* Reload a command
* @returns {Promise<Collection<string, Command> | ShewenyError>} The Application Commands collection
*/
reload(): Promise<Command | ShewenyError>;
/**
* Unregister a command from collections
* @returns {boolean}
*/
unregister(): boolean;
}