Command

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

arrow_forward
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

    subCommand

    SubCommand to be added

    arrow_forward
    No value returned
  • 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

    No arguments
    arrow_forward
    nullable
  • getParent()nullable {Command}

    Returns the parent command, if set

    No arguments
    arrow_forward
    nullable
  • 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)

    label
    {String}
    arrow_forward
    No value returned
  • getSubCommands() → {Array.<Command>}

    Returns all the subCommands of a command

    No arguments
    arrow_forward
    {Array.<Command>}
  • getTabCompleter()nullable {Command#tabCompleter}

    Returns the tab completion callback of the command, if set

    No arguments
    arrow_forward
  • 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_forward

    the 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

    subCommand
    {String}
    arrow_forward
    {boolean}
  • matchesName(name, aliasesopt) → {boolean}

    Returns whether or not the name matches the name and optionally any alias

    name

    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_forward

    Possible values for the completion

    {Array.<String>}
  • removeSubCommand(subCommand)

    Removes, if present, a subCommand from the command

    subCommand
    arrow_forward
    No value returned
  • setAliases(…aliases)

    Adds aliases to the Command

    aliases
    {String}
    {Array.<String>}
    arrow_forward
    No value returned
  • setDescription(description)

    Sets the description of a command

    description
    arrow_forward
    No value returned
    Throws:
    TODO: exception
  • setExecutor(executor)

    Sets the executor of this command

    executor
    arrow_forward
    No value returned
    Throws:
    TODO: exception
  • setParent(parent)

    Sets the parent command

    parent
    arrow_forward
    No value returned
  • setPermissionRequired(permissionRequired)

    Sets the required permission for the Command

    permissionRequired

    The required permission

    {String}
    arrow_forward
    No value returned
    Throws:
    TODO: exception
  • setTabCompleter(tabCompleter)

    Sets the tab completer of the command

    tabCompleter

    The tab completer callback to be set

    arrow_forward
    No value returned
    Throws:
    TODO: exception
  • setUsage(usage)

    Sets the usage for the command

    usage
    arrow_forward
    No value returned
    Throws:
    TODO: exception
` : '' ?>