Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Command

Base class for all Klasa Commands. See {@tutorial CreatingCommands} for more information how to use this class to build custom commands.

tutorial

CreatingCommands

Hierarchy

Index

Constructors

constructor

Properties

aliases

aliases: string[]

The aliases for this piece.

since

0.0.1

Readonly client

client: Client

The client this Piece was created with.

since

0.0.1

cooldownLevel

cooldownLevel: CooldownLevel

The level at which cooldowns should apply

since

0.5.0

cooldowns

cooldowns: RateLimitManager

The cooldowns for this command

since

0.6.0

deletable

deletable: boolean

Whether this command should have it's responses deleted if the triggering message is deleted

since

0.5.0

description

description: string | ((language: Language) => string)

The description of the command

since

0.0.1

Readonly directory

directory: string

The base directory this Piece is stored in.

since

0.0.1

enabled

enabled: boolean

Whether or not the Piece is enabled.

since

0.0.1

extendedHelp

extendedHelp: string | ((language: Language) => string)

The extended help for the command

since

0.0.1

Readonly file

file: keyof string[]

The file location where this Piece is stored.

since

0.0.1

flagSupport

flagSupport: boolean

Whether to use flag support for this command or not

since

0.2.1

fullCategory

fullCategory: string[]

The full category for the command

since

0.0.1

guarded

guarded: boolean

Whether this command should not be able to be disabled in a guild or not

since

0.5.0

hidden

hidden: boolean

Whether this command is hidden or not

since

0.5.0

name

name: string

The name of the Piece.

since

0.0.1

nsfw

nsfw: boolean

Whether this command should only run in NSFW channels or not

since

0.5.0

permissionLevel

permissionLevel: number

The required permissionLevel to run this command

since

0.0.1

promptLimit

promptLimit: number

The number or attempts allowed for re-prompting an argument

since

0.5.0

promptTime

promptTime: number

The time allowed for re-prompting of this command

since

0.5.0

quotedStringSupport

quotedStringSupport: boolean

Whether to use quoted string support for this command or not

since

0.2.1

requiredPermissions

requiredPermissions: Permissions

The required bot permissions to run this command

since

0.0.1

requiredSettings

requiredSettings: string[]

The required per guild settings to run this command

since

0.0.1

runIn

runIn: ChannelType[]

What channels the command should run in

since

0.0.1

Readonly store

store: Store<Piece>

The store this Piece is from.

since

0.0.1

subcommands

subcommands: boolean

Whether to enable subcommands or not

since

0.5.0

usage

The parsed usage for the command

since

0.0.1

Accessors

category

  • get category(): string

path

  • get path(): string
  • The absolute path to this piece

    since

    0.0.1

    Returns string

subCategory

  • get subCategory(): string

type

  • get type(): string
  • The type of piece this is

    since

    0.0.1

    Returns string

Methods

createCustomResolver

  • createCustomResolver(type: string, resolver: (arg: any, possible: Possible, message: Message, args: any[]) => any): this
  • Registers a one-off custom resolver. See tutorial {@link CommandsCustomResolvers}

    since

    0.5.0

    chainable

    Parameters

    • type: string

      The type of the usage argument

    • resolver: (arg: any, possible: Possible, message: Message, args: any[]) => any

      The one-off custom resolver

    Returns this

customizeResponse

  • customizeResponse(name: string, response: string | ((message: Message) => string)): this
  • Customizes the response of an argument if it fails resolution. See tutorial {@link CommandsCustomResponses}

    since

    0.5.0

    chainable
    example

    // Changing the message for a parameter called 'targetUser' this.customizeResponse('targetUser', 'You did not give me a user...');

    // Or also using functions to have multilingual support: this.customizeResponse('targetUser', (message) => message.language.get('COMMAND_REQUIRED_USER_FRIENDLY'));

    Parameters

    • name: string

      The name of the usage argument

    • response: string | ((message: Message) => string)

      The custom response or i18n function

    Returns this

definePrompt

  • definePrompt(usageString: string, usageDelim: string): Usage
  • Creates a Usage to run custom prompts off of

    Parameters

    • usageString: string

      The string designating all parameters expected

    • usageDelim: string

      The string to delimit the input

    Returns Usage

disable

  • disable(): this
  • Disables this piece

    since

    0.0.1

    chainable

    Returns this

enable

  • enable(): this
  • Enables this piece

    since

    0.0.1

    chainable

    Returns this

init

  • init(): unknown
  • The init method to be optionally overwritten in actual pieces

    since

    0.0.1

    Returns unknown

reload

  • reload(): Promise<Piece | null>
  • Reloads this piece

    since

    0.0.1

    Returns Promise<Piece | null>

    The newly loaded piece

Optional run

  • The run method to be overwritten in actual commands

    since

    0.0.1

    Parameters

    • message: Message

      The command message mapped on top of the message used to trigger this command

    • params: any[]

      The fully resolved parameters based on your usage / usageDelim

    Returns Promise<Message[]>

    You should return the response message whenever possible

toJSON

  • toJSON(): Record<string, any>

toString

  • toString(): string
  • Defines toString behavior for pieces

    since

    0.0.1

    Returns string

    This piece name

unload

  • unload(): boolean
  • Unloads this piece

    since

    0.0.1

    Returns boolean

Generated using TypeDoc