Constructor
new Command(name, parentopt)
The Command class, represents an executable command. It handles usage definition, subcommands, tab completion and aliases.
name |
Name of the Command |
{String}
|
parent opt |
Parent Command, used by Command#addSubCommand |
{Command}
|
No value returned
Methods
-
addSubCommand(subCommand)
Adds a subCommand to the command, will do nothing if the subCommand already has a parent or if there is already another subCommand with the same name or alias
-
getAliases() → {Array.<String>}
Returns all the aliases
No arguments
arrow_forward{Array.<String>} -
getDescription(senderopt) → {String}
Returns the description of the command
sender opt If Command#description is a function, it will call this function with
sender
as argument. Represents the sender/author of the command call{*}arrow_forward{String} -
getExecutor() → nullable {Command#executor}
Returns the
executor
of this command, if set -
getPermissionRequired() → {String}
Returns the permission required for the
Command
No arguments
arrow_forward{String} -
getSubCommand(label)
Returns, if found, a subCommand matching
label
(name or alias) -
getTabCompleter() → nullable {Command#tabCompleter}
Returns the tab completion callback of the command, if set
-
getUsage(senderopt) → {String}
Returns the usage of the command
sender opt The sender/author-representing object, will be passed to the Command~usageCallback
{*}arrow_forward{String} -
handleExecution(context, label, args) → {CommandResult}
Execution handler; the function you should call when the command has been invoked. It does argument and permission checks and propagates the call to subCommands
context Context of the call
label Name by which the command was invoked
{String}args Arguments for the command
{Array.<String>}arrow_forwardthe result of the call. If the arguments are invalid, a CommandResult.ERROR_USAGE will be returned and if the permissions are invalid, the return value will be CommandResult.ERROR_PERMISSION.
Throws:
TODO: exception -
hasParent() → {boolean}
Returns whether or not the command is a child command
No arguments
arrow_forward{boolean} -
hasSubCommand(subCommand) → {boolean}
Returns whether or not a subCommand is present in the command
-
matchesName(name, aliasesopt) → {boolean}
Returns whether or not the
name
matches the name and optionally any aliasname The name to compare to
{String}aliases opt = true Whether or not it should search within the aliases aswell
{boolean}arrow_forward{boolean} -
onTabComplete(context, label, args) → {Array.<String>}
The handler for the tab completion event, it will return all of the possibilities as a String array
context Context of the tab completion call
label Label of the command
{String}args Arguments already typed in
{Array.<String>}arrow_forwardPossible values for the completion
{Array.<String>} -
removeSubCommand(subCommand)
Removes, if present, a subCommand from the command
-
setAliases(…aliases)
Adds aliases to the
Command
… aliases {String}{Array.<String>}arrow_forwardNo value returned
-
setDescription(description)
Sets the description of a command
Throws:
TODO: exception -
setExecutor(executor)
Sets the
executor
of this commandThrows:
TODO: exception -
setPermissionRequired(permissionRequired)
Sets the required permission for the
Command
permissionRequired The required permission
{String}arrow_forwardNo value returned
Throws:
TODO: exception -
setTabCompleter(tabCompleter)
Sets the tab completer of the command
tabCompleter The tab completer callback to be set
arrow_forwardNo value returned
Throws:
TODO: exception -
setUsage(usage)
Sets the usage for the command
Throws:
TODO: exception