Represents a command.

type of the command.

Type Parameters

  • T extends "built-in" | "custom" | "unknown" = "unknown"

Constructors

  • Creates an instance of the command class.

    Type Parameters

    • T extends "built-in" | "custom" | "unknown" = "unknown"

    Parameters

    • command:
          | Globals.modules.cmds.command<T>
          | {
              category?: string | string[];
              command_version?: string | number;
              commandName: string;
              commands_format_version?: string | number;
              commandSettingsId?: string;
              customCommandCodeLines?: number;
              customCommandId?: string;
              customCommandParametersEnabled?: boolean;
              customCommandParametersList?: evaluateParametersArgumentTypes[];
              customCommandPrefix?: string;
              customCommandType?: "commands" | "javascript";
              description?: string;
              escregexp?: { f?: string; v: string };
              format_version?: string | number;
              formats?: command_formats_type_list;
              formatting_code?: string;
              type: T;
          }

      The command to create.

    Returns Globals.modules.cmds.command<T>

    An instance of the command class.

Properties

categories?: string[]

The categories of the command.

This is used in the manage commands menu to determine where it should appear.

category?: string | string[]

The category(ies) of the command.

This is used in the manage commands menu to determine where it should appear.

command_version?: string | number

The version of the command.

commandName: string

The name of the command.

commands_format_version: string | number = commands_format_version

The commands format version that the command was created in.

commandSettingsId: string

The ID of the command settings.

currentCommandName: string

The currently entered command name, either the command name or an alias.

currentescregexp?: { f?: string; v: string }

The current escaped regular expression to determine if a string is this command, either the regular expression or the regular expression of an alias.

customCommandCodeLines?: number

The number of lines of code in the custom command.

customCommandId?: string

The ID of the custom command.

customCommandParametersEnabled?: boolean

Whether parameters should be automatcially evaluated for the command.

customCommandParametersList?: evaluateParametersArgumentTypes[]

The list of parameters of the custom command.

customCommandPrefix?: string

The prefix of the custom command.

customCommandType?: "commands" | "javascript"

The type of the custom command.

  • "commands": The custom command uses vanilla Minecraft commands.
  • "javascript": The custom command uses javascript.
description?: string

The description of the command.

escregexp?: { f?: string; v: string }

The escaped regular expression to determine if a string is this command.

format_version: string | number = format_version

The version of the add-on that custom command was created in.

The syntaxes of the command.

formatting_code: string = "§r§f"

The formatting code of the command.

parameters?: {
    displayType?: string;
    evaluationType?: string;
    internalType?: evaluateParametersArgumentTypes;
    name: string;
    type?: string;
}[]

The parameters of the command.

Only applies to custom commands.

Type declaration

  • OptionaldisplayType?: string

    The display type of the parameter.

  • OptionalevaluationType?: string

    The evaluation type of the parameter.

  • OptionalinternalType?: evaluateParametersArgumentTypes

    The internal type of the parameter.

  • name: string

    The name of the parameter.

  • Optionaltype?: string

    The type of the parameter.

selectedalias?: {
    alias: {
        aliasTo?: string;
        commandName: string;
        escregexp?: { f?: string; v: string };
        regexp: RegExp;
    };
    index: number;
}

The currently selected alias of the command, if the user is using an alias.

Type declaration

  • alias: {
        aliasTo?: string;
        commandName: string;
        escregexp?: { f?: string; v: string };
        regexp: RegExp;
    }

    The details of the alias.

    • OptionalaliasTo?: string

      The name of the command the alias is an alias of.

    • commandName: string

      The name of the alias.

    • Optionalescregexp?: { f?: string; v: string }

      The escaped regular expression of the alias.

    • regexp: RegExp

      The regular expression of the alias.

  • index: number

    The index of the alias.

type: T

The type of the command.

  • "built-in": Built-in command.
  • "custom": Custom command.
  • "unknown": Unknown command type.

Accessors

  • get aliases(): T extends "built-in"
        ? {
            aliasTo?: string;
            commandName: string;
            escregexp?: { f?: string; v: string };
            regexp: RegExp;
        }[]
        : undefined

    The aliases of the command.

    Only available if the command is a built-in command.

    Returns T extends "built-in"
        ? {
            aliasTo?: string;
            commandName: string;
            escregexp?: { f?: string; v: string };
            regexp: RegExp;
        }[]
        : undefined

  • get code(): string[]

    The code of the custom command.

    If customCommandType is commands, the code will be a list of strings with vanilla Minecraft commands.

    If customCommandType is javascript, the code will be a list of strings that represent lines of JavaScript code, this should be merged together with newline characters.

    Returns string[]

    If the command is not a custom command (Tests if the type property is custom).

    If the customCommandId property is undefined.

  • get currentregexp(): RegExp

    The current regular expression to determine if a string is this command, will be either the parsed regexp of the command or on of its aliases.

    Returns RegExp

  • get isDeprecated(): boolean

    If the command is deprecated.

    Returns boolean

  • get isFunctional(): boolean

    If the command is functional.

    Returns boolean

  • get isHidden(): boolean

    If the command is hidden.

    Returns boolean

  • get regexp(): RegExp

    The regular expression to determine if a string is this command.

    Returns RegExp

  • get releaseStage(): string

    The release stage of the command.

    Returns string

  • get ultraSecurityModeSecurityLevel(): | "admin"
    | "WorldEdit"
    | "owner"
    | "headAdmin"
    | "moderator"
    | "everyone"

    The ultra security mode security level of the command.

    Only applies when ultra security mode is enabled.

    • owner: Only the owner or people with the andexdb.fullControl or andexdb.useOwnerLevelCommands permissions can execute the command.
    • headAdmin: Only players with the andexdb.headAdmin or andexdb.useHeadAdminLevelCommands permissions can execute the command.
    • admin: Only players with the andexdb.admin or andexdb.useAdminLevelCommands permissions can execute the command.
    • moderator: Only players with the andexdb.moderator or andexdb.useModeratorLevelCommands permissions can execute the command.
    • WorldEdit: Only players with the andexdb.WorldEdit permission can execute the command.
    • everyone: Everyone can execute the command.

    Returns "admin" | "WorldEdit" | "owner" | "headAdmin" | "moderator" | "everyone"

  • get defaultPrefix(): string

    The current prefix set for the chat commands.

    Returns string

    "\\"
    
  • get dp(): string

    The current prefix set for the chat commands.

    This is an alias of defaultPrefix.

    Returns string

    "\\"
    

Methods

  • Removes the current command if it is a custom command.

    Returns void

    If the command is not a custom command (Tests if the type property is custom).

    If the customCommandId property is undefined.

  • Runs the custom command.

    Parameters

    Returns void

    If the command is not a custom command (Tests if the type property is custom).

    If the customCommandId property is undefined.

    If the vanilla minecraft command throws an error.

    If the custom command throws an error.

    If the custom JavaScript code throws an error.

  • Saves the custom command.

    Returns string

    The ID of the custom command.

    If the command is not a custom command (Tests if the type property is custom).

    If the customCommandId property is undefined.

  • Tests if the given player can use this command.

    Parameters

    Returns boolean

    True if the player can use this command, false otherwise. If the player is an instance of the executeCommandPlayerW class, and there is no linked player, or the linked player is not online, the function will return false.

    If player is not an instance of the Player class or an instance of the executeCommandPlayerW class with a Player linked to it.

  • Gets a built-in command.

    Parameters

    • commandString: string

      The command string to detect the command from.

    • OptionalreturnCommandInsteadOfAlias: boolean = false

      Whether or not to always return the main command, even if the detected command is an alias.

    Returns
        | {
            aliases?: {
                commandName: string;
                escregexp?: { f?: string; v?: string };
            }[];
            category?: commandCategory
            | commandCategory[];
            command_version: string;
            commandName: string;
            commandSettingsId: string;
            deprecated: boolean;
            description: string;
            enabled: boolean;
            escregexp: { f?: string; v: string };
            formats: command_formats_type_list;
            formatting_code: string;
            functional: boolean;
            hidden: boolean;
            requiredTags: string[];
            type: "built-in";
            ultraSecurityModeSecurityLevel:
                | "admin"
                | "WorldEdit"
                | "owner"
                | "headAdmin"
                | "moderator"
                | "everyone";
        }
        | {
            alias: { commandName: string; escregexp?: { f?: string; v?: string } };
            aliasTo: {
                aliases?: {
                    commandName: string;
                    escregexp?: { f?: string; v?: string };
                }[];
                category?: commandCategory
                | commandCategory[];
                command_version: string;
                commandName: string;
                commandSettingsId: string;
                deprecated: boolean;
                description: string;
                enabled: boolean;
                escregexp: { f?: string; v: string };
                formats: command_formats_type_list;
                formatting_code: string;
                functional: boolean;
                hidden: boolean;
                requiredTags: string[];
                type: "built-in";
                ultraSecurityModeSecurityLevel:
                    | "admin"
                    | "WorldEdit"
                    | "owner"
                    | "headAdmin"
                    | "moderator"
                    | "everyone";
            };
            index: number;
        }

    The built-in command.

  • Gets a command.

    Type Parameters

    • T extends "built-in" | "custom" | "unknown" = "built-in"

      The type of the command.

    Parameters

    • commandName: string

      The name of the command.

    • Optionaltype: T

      The type of the command.

    Returns Globals.modules.cmds.command<T>

    The command.

  • Gets all of the aliases of the built-in commands.

    Returns {
        [key: string]: {
            commandName: string;
            escregexp?: { f?: string; v?: string };
        }[];
    }

    The aliases of the built-in commands.

  • Gets all of the custom commands.

    Parameters

    • OptionalnoSort: boolean = false

      If set to true, it will not sort the commands.

    Returns Globals.modules.cmds.command<"custom">[]

    The array of custom commands.

  • Gets the built-in commands.

    Parameters

    • OptionalnoSort: boolean = false

      If set to true, it will not sort the commands.

    Returns Globals.modules.cmds.command<"built-in">[]

    The array of built-in commands.

  • Gets the built-in commands of a category.

    Parameters

    • category: commandCategory

      The category of the commands.

    • OptionalnoSort: boolean = false

      If set to true, it will not sort the commands.

    Returns Globals.modules.cmds.command<"built-in">[]

    The array of built-in commands.