Class: Command

Command

Base class for all Klasa Commands. See Creating Commands for more information how to use this class to build custom commands.

new Command(client, dir, file [, options])

Parameters:
Name Type Argument Default Description
client KlasaClient The Klasa Client
dir string The path to the core or user command pieces folder
file Array The path from the pieces folder to the command file
options CommandOptions <optional>
{} Optional Command settings
Since:
  • 0.0.1
Implements:
Source:
lib/structures/Command.js#L37
Tutorials:

Properties


aliases :Array.<string>

The aliases for this command
Type:
  • Array.<string>
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L77

botPerms :Array.<string>

The required bot permissions to run this command
Type:
  • Array.<string>
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L91

category :string

The main category for the command
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L154

client :KlasaClient

Type:
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L42

cooldown :number

The cooldown in seconds this command has
Type:
  • number
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L70

description :string

The description of the command
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L112

dir :string

The directory to where this command piece is stored
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L190

enabled :boolean

If the command is enabled or not
Type:
  • boolean
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L56

extendedHelp :string

The extended help for the command
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L119

file :Array.<string>

The file location where this command is stored
Type:
  • Array.<string>
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L183

fullCategory :Array.<string>

The full category for the command
Type:
  • Array.<string>
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L147

name :string

The name of the command
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L105

permLevel :number

The required permLevel to run this command
Type:
  • number
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L84

quotedStringSupport :boolean

Whether to use quoted string support for this command or not
Type:
  • boolean
Since:
  • 0.2.1
Source:
lib/structures/Command.js#L140

requiredSettings :Array.<string>

The required guild settings to run this command
Type:
  • Array.<string>
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L98

runIn :Array.<string>

What channels the command should run in
Type:
  • Array.<string>
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L63

subCategory :string

The sub category for the command
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L161

type :string

The type of Klasa piece this is
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L49

usage :ParsedUsage

The parsed usage for the command
Type:
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L168

<nullable> usageDelim :string

The usage deliminator for the command input
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L133

usageString :string

The usage string for the command
Type:
  • string
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L126

Methods


disable()

Disables this piece
Since:
  • 0.0.1
Implements:
Source:
lib/structures/interfaces/Piece.js#L43
Returns:
This piece
Type
Piece

enable()

Enables this piece
Since:
  • 0.0.1
Implements:
Source:
lib/structures/interfaces/Piece.js#L54
Returns:
This piece
Type
Piece

<async, abstract> init()

The init method to be optionaly overwritten in actual commands
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L211
Returns:
Type
void

<async> reload()

Reloads this piece
Since:
  • 0.0.1
Implements:
Source:
lib/structures/interfaces/Piece.js#L21
Returns:
The newly loaded piece
Type
Piece

<async, abstract> run(msg, params)

The run method to be overwritten in actual commands
Parameters:
Name Type Description
msg CommandMessage The command message mapped on top of the message used to trigger this command
params Array.<any> The fully resolved parameters based on your usage / usageDelim
Since:
  • 0.0.1
Source:
lib/structures/Command.js#L201
Returns:
You should return the response message whenever possible
Type
external:Message

unload()

Unloads this piece
Since:
  • 0.0.1
Implements:
Source:
lib/structures/interfaces/Piece.js#L33
Returns:
Type
void

Type Definitions


CommandOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
name string <optional>
theFileName The name of the command
enabled boolean <optional>
true Whether the command is enabled or not
runIn Array.<string> <optional>
['text','dm','group'] What channel types the command should run in
cooldown number <optional>
0 The amount of time before the user can run the command again in seconds
aliases Array.<string> <optional>
[] Any comand aliases
permLevel number <optional>
0 The required permission level to use the command
botPerms Array.<string> <optional>
[] The required Discord permissions for the bot to use this command
requiredSettings Array.<string> <optional>
[] The required guild settings to use this command
description string <optional>
'' The help description for the command
usage string <optional>
'' The usage string for the command
usageDelim string <optional>
<nullable>
The string to deliminate the command input for usage
quotedStringSupport boolean <optional>
this.client.config.quotedStringSupport Wheter args for this command should not deliminated inside quotes
extendedHelp string <optional>
'No extended help available.' Extended help strings
Source:
lib/structures/Command.js#L12