command.js

1.0.0

Classes

Definition for Classes

Command

Class representing a Command

Command
Parameters
cmd (string) The Command which should be used
Instance Members
_throttle
getCommandName()
getFullCommandName()
forcePrefix(prefix)
getPrefix()
help(text)
hasHelp()
getHelp()
throttle(throttle)
disable()
enable()
isEnabled()
exec(fnc)
dispatchCommand(args, ev)
manual(text)
hasManual()
getManual()
getUsage()
checkPermission(fnc)
isAllowed(client)
run(args, ev)
validate(args)
validateArgs(args)
addArgument(argument)
getArguments()

CommandGroup

Class representing a CommandGroup

CommandGroup

Extends Command

Parameters
cmd (string) The Command which should be used
Instance Members
addArgument()
addCommand(name)
findSubCommandByName(name)
getAvailableSubCommands(client?, cmd?)
isAllowed(client)
run(args, ev)

SubCommand

Class representing a SubCommand which will be used within CommandGroups

SubCommand

Extends Command

Parameters
cmd (string) The Command Name which should be used
Instance Members
getPrefix()
setPrefix()
getUsage()

CommandCollector

A collection of registered commands in this library

CommandCollector
Static Members
validateCommandName(name, allowSingleChar)
Instance Members
getAvailableCommandsWithPrefix(cmd)
isPossibleCommand(cmd)
getPrefixes()
registerCommand(cmd)
getAvailableCommands(client?, cmd?)
getCommandByName(name)

Throttle

Class representing a Command

Throttle
Instance Members
tickRate(duration)
penaltyPerCommand(amount)
restorePerTick(amount)
initialPoints(initial)
throttle(client)
isThrottled(client)
timeTillNextCommand(client)

Argument Types

Available Argument Types which can be added to a Command

Argument

Class representing an Argument

Argument
Instance Members
optional(fallback?, displayDefault)
getDefault()
hasDefault()
getManual()
isOptional()
setName(name, display?)
getName()

NumberArgument

Class representing a NumberArgument this will try to parse a number

NumberArgument

Extends Argument

Instance Members
min(min)
max(max)
integer()
positive()
negative()

StringArgument

Class representing a StringArgument

StringArgument

Extends Argument

Instance Members
match(regex)
max(len)
min(len)
forceUpperCase()
forceLowerCase()
whitelist(words)

ClientArgument

Class representing a ClientArgument this Argument is capable to parse a Client UID or a simple UID inside the exec function it will resolve the found uid

ClientArgument

Extends Argument

RestArgument

Class representing a RestArgument this will parse everything remaining you can use all methods from the StringArgument here

RestArgument

Extends StringArgument

GroupArgument

Class representing a GroupArgument

GroupArgument

Extends Argument

Parameters
type (string) the type of the Argument, should be "and" or "or"
Instance Members
argument(args)

execFunction

execFunction(ev: MessageEvent)

Type: Function

Since: 1.2.3
Parameters

MessageEvent

MessageEvent

Type: object

Properties
text (string) : Text of the message
channel (Channel) : Channel (if given) this message has been sent on
client (Client) : Client that sent the message
mode (number) : Number representing the way this message has been sent (1 = private, 2 = channel, 3 = server)
message (DiscordMessage?) : When backend is discord this will be the callback parameter of the message event, otherwise undefined. Available since v1.3.0

Exports

These Functions gets exported as object when imported through require("command.js")

createCommand

Creates a new Command Instance with the given Command Name

createCommand
Parameters
cmd (string) the command which should be added
OVERRIDES (string?) enter "YES_I_KNOW_THAT_I_SHOULD_NOT_USE_COMMANDS_WITH_LENGTH_OF_ONE" to allow commands with the length of one
Returns
Command: returns the created Command

createCommandGroup

Creates a new CommandsCommand Instance with the given Command Name

createCommandGroup
Parameters
cmd (string) the command which should be added
OVERRIDES (string?) enter "YES_I_KNOW_THAT_I_SHOULD_NOT_USE_COMMANDS_WITH_LENGTH_OF_ONE" to allow commands with the length of one
Returns
CommandGroup: returns the created CommandGroup instance

createArgument

Creates a new Argument Instance

createArgument
Parameters
type (string) the argument type which should be created
Returns
Argument: returns the created Argument

createGroupedArgument

Creates a new Argument Instance

createGroupedArgument
Parameters
type (string) the argument type which should be created either "or" or "and" allowed
Returns
GroupArgument: returns the created Group Argument

getCommandPrefix

retrieves the current Command Prefix

getCommandPrefix
Returns
string: returns the command prefix

collector

collector

Type: CommandCollector

getVersion

retrieves the semantic version of this script

getVersion
Returns
string: returns the semantic version of this script

createThrottle

Creates a new Throttle Instance

createThrottle
Returns
Throttle: returns the created Throttle

CommandDisabledError

Class representing a CommandDisabledError

new CommandDisabledError(err: any)

Extends Error

Parameters
err (any)