Class CommandAbstract

Represents a command.

Example

class Ping extends Command {
name = 'ping';

execute(message) {
message.reply('Pong!');
}
}

Hierarchy

  • Command

Constructors

Properties

aliases: string[] = []

The aliases of the command.

arguments: ArgumentConstructor[] = []

The options of the command.

client: Client

The client the command belongs to.

cooldown: number

The cooldown of the command.

cooldowns: Collection<string, number> = ...

The cooldowns of the command.

description?: string

The description of the command.

name: string

The name of the command.

Methods

  • The execute method of the command.

    Example

    execute(message, { content }) {
    message.reply(content);
    }

    Parameters

    • message: Message

      The message that triggered the command.

    • args: Record<string, unknown>

      The arguments of the command.

    Returns unknown

  • Get the usage of the command.

    Returns

    The usage of the command.

    Example

    command.getUsage();
    

    Parameters

    • Optional serverId: string

      The ID of the server the command is used in.

    Returns string

  • Set a cooldown for a user.

    Example

    command.setCooldown('abc');
    

    Parameters

    • userId: string

      The ID of the user to set the cooldown for.

    Returns void

  • Validate the command.

    Returns

    The validated arguments.

    Example

    command.validate(message, ['hello', 'world']); // { content: 'hello world' }
    

    Parameters

    • message: Message

      The message that triggered the command.

    • args: string[]

      The arguments of the command.

    Returns Promise<Record<string, unknown>>

  • Validate the command arguments.

    Returns

    The validated arguments.

    Example

    command.validateArguments(['hello', 'world']); // { content: 'hello world' }
    

    Parameters

    • args: string[]

      The arguments to validate.

    Returns Promise<Record<string, unknown>>