@guildedts/framework
Version:
A framework for creating a Guilded bot.
73 lines • 2.56 kB
TypeScript
import { Collection } from '@discordjs/collection';
import { Message } from 'guilded.ts';
import { ArgumentConstructor } from './arguments/Argument';
import { Client } from './Client';
/**
* Represents a command.
* @example
* class Ping extends Command {
* name = 'ping';
*
* execute(message) {
* message.reply('Pong!');
* }
* }
*/
export declare abstract class Command {
readonly client: Client;
/** The name of the command. */
name: string;
/** The aliases of the command. */
aliases: string[];
/** The description of the command. */
description?: string;
/** The options of the command. */
arguments: ArgumentConstructor[];
/** The cooldown of the command. */
cooldown: number;
/** The cooldowns of the command. */
readonly cooldowns: Collection<string, number>;
/** @param client The client the command belongs to. */
constructor(client: Client);
/**
* Get the usage of the command.
* @param serverId The ID of the server the command is used in.
* @returns The usage of the command.
* @example command.getUsage();
*/
getUsage(serverId?: string): string;
/**
* The execute method of the command.
* @param message The message that triggered the command.
* @param args The arguments of the command.
* @example
* execute(message, { content }) {
* message.reply(content);
* }
*/
abstract execute(message: Message, args: Record<string, unknown>): unknown;
/**
* Validate the command.
* @param message The message that triggered the command.
* @param args The arguments of the command.
* @returns The validated arguments.
* @example command.validate(message, ['hello', 'world']); // { content: 'hello world' }
*/
validate(message: Message, args: string[]): Promise<Record<string, unknown>>;
/**
* Validate the command arguments.
* @param args The arguments to validate.
* @returns The validated arguments.
* @example command.validateArguments(['hello', 'world']); // { content: 'hello world' }
*/
validateArguments(args: string[]): Promise<Record<string, unknown>>;
/**
* Set a cooldown for a user.
* @param userId The ID of the user to set the cooldown for.
* @example command.setCooldown('abc');
*/
setCooldown(userId: string): void;
}
/** The constructor for a command. */
export declare type CommandConstructor = new (client: Client) => Command;
//# sourceMappingURL=Command.d.ts.map