Class: CommandStore

CommandStore

Stores all the commands usable in Klasa

new CommandStore(client)

Constructs our CommandStore for use in Klasa
Parameters:
Name Type Description
client KlasaClient The Klasa Client
Since:
  • 0.0.1
Implements:
Source:
lib/structures/CommandStore.js#L19

Extends

Properties


aliases :external:Collection

The different aliases that represent the commands in this store.
Type:
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L36

<readonly> client :KlasaClient

The client this CommandStore was created with.
Type:
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L22

coreDir :String

The directory of commands in Klasa relative to where its installed.
Type:
  • String
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L43

holds :Command

The type of structure this store holds
Type:
Since:
  • 0.1.1
Source:
lib/structures/CommandStore.js#L57

name :String

The name of what this holds
Type:
  • String
Since:
  • 0.3.0
Source:
lib/structures/CommandStore.js#L64

userDir :String

The directory of local commands relative to where you run Klasa from.
Type:
  • String
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L50

Methods


<async, static> walk(store, dir, subs)

Walks our directory of commands for the user and core directories.
Parameters:
Name Type Description
store CommandStore The command store we're loading into.
dir string The directory of commands we're using to load commands from.
subs Array.<string> Subfolders for recursion.
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L152
Returns:
Type
void

clear()

Clears the commands and aliases from this store
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L121
Returns:
Type
void

delete(name)

Deletes a command from the store.
Parameters:
Name Type Description
name Command | string A command object or a string representing a command or alias name.
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L108
Returns:
whether or not the delete was successful.
Type
boolean

get(name)

Returns a command in the store if it exists by its name or by an alias.
Parameters:
Name Type Description
name string A command or alias name.
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L73
Returns:
Type
Command

has(name)

Returns a boolean if the command or alias is found within the store.
Parameters:
Name Type Description
name string A command or alias name
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L82
Returns:
Type
boolean

init()

Initializes all pieces in this store.
Since:
  • 0.0.1
Implements:
Source:
lib/structures/interfaces/Store.js#L22
Returns:
Type
Array

<async> loadAll()

Loads all of our commands from both the user and core directories.
Since:
  • 0.0.1
Implements:
Source:
lib/structures/CommandStore.js#L131
Returns:
The number of commands and aliases loaded.
Type
number

resolve(name)

Resolve a string or piece into a piece object.
Parameters:
Name Type Description
name Piece | string The piece object or a string representing a piece's name
Since:
  • 0.0.1
Implements:
Source:
lib/structures/interfaces/Store.js#L68
Returns:
Type
Piece

set(command)

Sets up a command in our store.
Parameters:
Name Type Description
command Command The command object we are setting up.
Since:
  • 0.0.1
Source:
lib/structures/CommandStore.js#L92
Returns:
Type
Command