### Server Setup Example Source: https://eryn.io/Cmdr/guide/Setup Example of how to set up Cmdr on the server, including registering default commands or custom command folders. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Cmdr = require(path.to.Cmdr) Cmdr:RegisterDefaultCommands() -- This loads the default set of commands that Cmdr comes with. (Optional) -- Cmdr:RegisterCommandsIn(script.Parent.CmdrCommands) -- Register commands from your own folder. (Optional) ``` -------------------------------- ### Client Setup Example Source: https://eryn.io/Cmdr/guide/Setup Example of how to set up Cmdr on the client, including requiring the CmdrClient module and setting activation keys. ```lua local ReplicatedStorage = game:GetService("ReplicatedStorage") local Cmdr = require(ReplicatedStorage:WaitForChild("CmdrClient")) -- Configurable, and you can choose multiple keys Cmdr:SetActivationKeys({ Enum.KeyCode.F2 }) -- See below for the full API. ``` -------------------------------- ### Cmdr Run Command Example Source: https://eryn.io/Cmdr/guide/MetaCommands Example of using the `run` command in Cmdr to execute a command string with an embedded command. Demonstrates how embedded commands are evaluated and their output is used in the main command. ```lua run ${{"echo kill me"}} ``` -------------------------------- ### Cmdr Alias Command Example Source: https://eryn.io/Cmdr/guide/MetaCommands Demonstrates creating a new command 'farewell' that announces a message and then kills a specified player. It shows how to use arguments ($1) and chain commands with '&&'. ```Cmdr alias farewell announce Farewell, $1! && kill $1 ``` -------------------------------- ### Cmdr Alias with Typed Arguments Source: https://eryn.io/Cmdr/guide/MetaCommands Shows how to define typed arguments for an alias, including optional name and description for clarity and validation. The example defines a 'player' type for the $1 argument. ```Cmdr alias goodbye kill $1{player|Player|The player you want to kill.} ``` ```Cmdr alias goodbye kill $1{player} ``` ```Cmdr alias goodbye kill $1{player|Player} ``` -------------------------------- ### Cmdr Alias with Hover Target Example Source: https://eryn.io/Cmdr/guide/MetaCommands Illustrates creating an 'pointer_of_death' alias that kills the player currently being hovered over, using the ${hover} variable. ```Cmdr alias pointer_of_death kill ${hover} ``` -------------------------------- ### Cmdr resolve command Source: https://eryn.io/Cmdr/guide/Commands The 'resolve' command retrieves the true value of operators as a list. It accepts a type and an operator, returning the list as a string. Examples demonstrate resolving players based on different wildcard patterns. ```APIDOC resolve command: Usage: resolve Description: Retrieves the true value of operators as a list. Arguments: type: The type of operator to resolve (e.g., 'players'). operator: The operator pattern (e.g., '.', '*', '**', '?'). Examples: resolve players . resolve players * resolve players ** resolve players ? ``` -------------------------------- ### CmdrClient Instance Methods Source: https://eryn.io/Cmdr/api/CmdrClient Methods for managing CmdrClient behavior, including setting activation keys, place name, and enabling/disabling the console. ```APIDOC CmdrClient:SetActivationKeys(keys: array) → void Sets the key codes that will hide or show Cmdr. Parameters: keys: array (Required) CmdrClient:SetPlaceName(labelText: string) → void Sets the place name label that appears when executing commands. This is useful for a quick way to tell what game you're playing in a universe game. Parameters: labelText: string (Required) CmdrClient:SetEnabled(isEnabled: boolean) → void Sets whether or not Cmdr can be shown via the defined activation keys. Useful for when you want users to need to opt-in to show the console in a settings menu. Parameters: isEnabled: boolean (Required) ``` -------------------------------- ### Util.GetNames Source: https://eryn.io/Cmdr/api/Util Extracts the 'Name' property from an array of objects, returning an array of strings. This is useful for getting a list of names from a collection of instances or other objects with a Name property. ```APIDOC Util.GetNames: Description: Accepts an array of instances (or anything with a Name property) and maps them into an array of their names. Parameters: instances: array<[NamedObject]> - An array of objects, each expected to have a 'Name' property. Returns: array - An array containing the 'Name' property of each input object. ``` -------------------------------- ### Cmdr CommandContext Methods Source: https://eryn.io/Cmdr/api/CommandContext Documentation for methods within the CommandContext class, including how to reply to commands and check for implementations. ```APIDOC CommandContext: Reply(text: str, color: str = None) Parameters: text: The text content of the reply (Required) color: The color for the reply (Optional) Returns: None HasImplementation() Returns: None ``` -------------------------------- ### Cmdr CommandContext Instance Methods Source: https://eryn.io/Cmdr/api/CommandContext Outlines the instance methods available on the CommandContext object for interacting with command execution and data. ```APIDOC GetArgument(index): Parameters: index (any): The index or key of the argument to retrieve. Returns: any: The requested argument. GetData(): Returns: any: Returns the data associated with the command context. GetStore(name): Parameters: name (string): The name of the store to retrieve. Returns: any: The requested store. SendEvent(player, event): Parameters: player (any): The player to send the event to. event (any): The event to send. BroadcastEvent(event, ...): Parameters: event (any): The event to broadcast. ... (any): Additional arguments to pass with the event. Reply(message): Parameters: message (string): The message to reply with. ``` -------------------------------- ### Cmdr API Reference Source: https://eryn.io/Cmdr/guide/Commands Provides an overview of the Cmdr API, including key classes like ArgumentContext, Cmdr, CmdrClient, CommandContext, Dispatcher, Registry, and Util. This reference is crucial for understanding and utilizing Cmdr's functionalities. ```APIDOC Cmdr: RegisterDefaultCommands() Registers a predefined set of default commands. Registry: CommandDefinition Defines the structure and metadata for a command. Properties: Name: string Aliases: {string} Description: string Group: string Args: {ArgumentDefinition} ArgumentDefinition: Type: string Name: string Description: string CommandContext: Represents a single command execution. Methods: GetPlayer(): Player Returns the player who executed the command. Reply(message: string) Sends a reply message to the console. SendEvent(eventName: string, ...) Sends a network event. CmdrClient: Handles client-side command interactions. Dispatcher: Manages the execution of commands. Util: Provides utility functions for Cmdr. ``` -------------------------------- ### Cmdr API Reference Source: https://eryn.io/Cmdr/guide/Types Provides an overview of the core Cmdr API components, including ArgumentContext, Cmdr, CmdrClient, CommandContext, Dispatcher, Registry, and Util. This is essential for understanding how to interact with the Cmdr framework programmatically. ```APIDOC Cmdr: new(options: table?) Creates a new Cmdr instance. options: Configuration options for Cmdr. CmdrClient: new(cmdr: Cmdr) Creates a new CmdrClient instance. cmdr: The Cmdr instance to associate with. CommandContext: new(cmdr: Cmdr, command: string, args: { [string]: any }) Creates a new CommandContext instance. cmdr: The Cmdr instance. command: The name of the command being executed. args: A dictionary of arguments passed to the command. ArgumentContext: new(commandContext: CommandContext, argumentName: string) Creates a new ArgumentContext instance. commandContext: The CommandContext. argumentName: The name of the argument. Dispatcher: new(cmdr: Cmdr) Creates a new Dispatcher instance. cmdr: The Cmdr instance. Registry: new() Creates a new Registry instance. RegisterCommand(command: string, callback: function) Registers a command with the registry. command: The name of the command. callback: The function to execute when the command is run. RegisterType(typeName: string, typeDefinition: table) Registers a custom type with the registry. typeName: The name of the type. typeDefinition: The definition of the custom type. GetType(typeName: string): table? Retrieves a registered type definition. typeName: The name of the type to retrieve. Util: ParseArgument(argumentContext: ArgumentContext, expectedType: string): any Parses an argument based on the expected type. argumentContext: The ArgumentContext. expectedType: The expected data type of the argument. FormatArgument(value: any, targetType: string): string Formats a value into a string representation for a given type. value: The value to format. targetType: The target data type. ``` -------------------------------- ### Dispatcher API Documentation Source: https://eryn.io/Cmdr/api/Dispatcher Detailed documentation for the Dispatcher class, covering its properties and instance methods for command execution. ```APIDOC Dispatcher: Properties: Cmdr: Cmdr | CmdrClient A reference to Cmdr. This may either be the server or client version of Cmdr depending on where the code is running. Instance Methods: Run(...: string) -> string This should be used to invoke commands programmatically as the local player. Accepts a variable number of arguments, which are all joined with spaces before being run. This function will raise an error if any validations occur, since it's only for hard-coded (or generated) commands. Parameters: ...: string (Required) Returns: string EvaluateAndRun(commandText: string, executor?: Player, options?: { Data: any?, IsHuman: boolean }) -> string Runs a command as the given player. If called on the client, only text is required. Returns output or error test as a string. Parameters: commandText: string (Required) executor: Player? (Optional) options: { Data: any?, IsHuman: boolean } (Optional) If Data is given, it will be available on the server with CommandContext.GetData Returns: string GetHistory() -> array Returns an array of the user's command history. Most recent commands are inserted at the end of the array. Returns: array ``` -------------------------------- ### Cmdr API Reference Source: https://eryn.io/Cmdr/index Provides an overview of the Cmdr API, including core classes like ArgumentContext, Cmdr, CmdrClient, CommandContext, Dispatcher, Registry, and Util. ```APIDOC Cmdr: __new(options?: CmdrOptions) Creates a new Cmdr instance. options: Configuration options for Cmdr. CmdrOptions: keybind: The key to open the console (default: Enum.KeyCode.GraveAccentAndTilde) enabled: Whether Cmdr is enabled (default: true) prefix: The prefix for commands (default: ":") theme: The console theme (default: CmdrTheme.Default) CmdrClient: __new(cmdr: Cmdr) Creates a new CmdrClient instance. cmdr: The Cmdr instance. RegisterCommand(command: Command) Registers a new command. command: The command to register. RegisterArgumentType(argumentType: ArgumentType) Registers a new argument type. argumentType: The argument type to register. Command: name: string description: string handler: function(context: CommandContext, ...) arguments: { [key: string]: Argument } Argument: type: string description: string optional: boolean ArgumentType: name: string resolve: function(context: ArgumentContext, input: string): any complete: function(context: ArgumentContext): { string }? ArgumentContext: cmdr: Cmdr command: Command argumentName: string input: string history: { string }? CommandContext: cmdr: Cmdr command: Command args: { [key: string]: any } player: Player message: string Dispatcher: __new(cmdr: Cmdr) Creates a new Dispatcher instance. cmdr: The Cmdr instance. Dispatch(message: string, player: Player) Dispatches a command message. message: The command message to dispatch. player: The player who sent the message. Registry: __new(cmdr: Cmdr) Creates a new Registry instance. cmdr: The Cmdr instance. RegisterCommand(command: Command) Registers a command. command: The command to register. GetCommand(name: string): Command? Gets a command by its name. name: The name of the command. Returns: The command or nil if not found. RegisterArgumentType(argumentType: ArgumentType) Registers an argument type. argumentType: The argument type to register. GetArgumentType(name: string): ArgumentType? Gets an argument type by its name. name: The name of the argument type. Returns: The argument type or nil if not found. Util: FormatKeyword(keyword: string): string Formats a keyword for display. keyword: The keyword to format. FormatDescription(description: string): string Formats a description for display. description: The description to format. ``` -------------------------------- ### Cmdr Meta-Commands: Command Strings and Embedded Commands Source: https://eryn.io/Cmdr/guide/MetaCommands Explanation of command strings used by `bind`, `alias`, and `run` in Cmdr. Describes how arguments are preprocessed and embedded commands are evaluated within these strings. Includes details on nesting embedded commands and handling spaces in command outputs. ```APIDOC Meta-Commands (bind, alias, run): Command Strings: - Raw text containing a command name and arguments. - Arguments are replaced using `$1`, `$2`, etc. - Embedded commands are evaluated before execution. Embedded Commands: - Syntax: `${command arg1 arg2 arg3}` - Evaluated just before the command string is run. - Return value is used as the output of the command. - Nestable: `run echo ${run echo ${echo hello}!}` - Literal syntax for multiple arguments: `${{"echo first second"}​}` Run Command: - Executes a command string immediately. - Evaluates embedded commands before running. - Alias: `>` - Multiple commands delimited by `&&`. - Escape `&&` with `&&&`. - Access previous command's output with `||` slot operator (e.g., `run echo evaera && kill ||`). ``` -------------------------------- ### Cmdr Properties Source: https://eryn.io/Cmdr/api/Cmdr Provides access to the core components of the Cmdr framework: Registry, Dispatcher, and Util. ```APIDOC Cmdr: Registry: read only Type: [Registry](https://eryn.io/Cmdr/api/Registry.html#registry) Description: Refers to the current command Registry. The registry handles registering commands, types, and hooks. Dispatcher: read only Type: [Dispatcher](https://eryn.io/Cmdr/api/Dispatcher.html#dispatcher) Description: Refers to the current command Dispatcher. The Dispatcher handles parsing, validating, and evaluating commands. Util: read only Type: [Util](https://eryn.io/Cmdr/api/Util.html#util) Description: Refers to a table containing many useful utility functions. ``` -------------------------------- ### Cmdr Registry API Documentation Source: https://eryn.io/Cmdr/api/Registry Provides methods for registering and retrieving commands within the Cmdr framework. Includes functions for registering commands, default commands, hooks, and accessing command stores. ```APIDOC Registry: RegisterCommandsIn(container, filter = null) Registers commands from a container, optionally applying a filter. Parameters: container: The container holding the commands. filter: An optional filter to apply to the commands. RegisterCommand(commandScript, commandServerScript = null, filter = null) Registers a single command. Parameters: commandScript: The script for the command. commandServerScript: An optional server script for the command. filter: An optional filter for the command. RegisterDefaultCommands(groups) Registers a set of default commands. Parameters: groups: The groups of default commands to register. GetCommand(name) Retrieves a specific command by its name. Parameters: name: The name of the command to retrieve. Returns: The command object if found. GetCommands() Retrieves all registered commands. Returns: A collection of all registered commands. GetCommandNames() Retrieves the names of all registered commands. Returns: A list of command names. RegisterHook(hookName, callback, priority = null) Registers a hook to be executed at a specific point. Parameters: hookName: The name of the hook. callback: The function to execute as the hook. priority: An optional priority for the hook. GetStore(name) Retrieves a store by its name. Parameters: name: The name of the store to retrieve. Returns: The store object if found. ``` -------------------------------- ### Cmdr API: Command Definition Source: https://eryn.io/Cmdr/guide/Commands Defines the structure for a Cmdr command, including optional Data, ClientRun, and Server implementations. ```APIDOC CommandDefinition: __new(name: string, options: table) name: The name of the command. options: A table containing optional functions: Data: function(context: Context) -> any Runs on the client to gather data. Returned data is available via context:GetData(). ClientRun: function(context: Context) -> string | nil Runs on the client. If it returns a string, the command execution stops on the client. If nil, the server implementation runs. Server: function(context: Context) -> any Runs on the server. This is the primary command implementation if ClientRun does not return a string. Hooks: table A table of hooks (BeforeRun, AfterRun) for client and server. Context: GetData(): any Retrieves data returned from the 'Data' function. GetClientData(): any Retrieves data returned from the 'ClientRun' function. GetServerData(): any Retrieves data returned from the 'Server' function. ``` -------------------------------- ### Implement Cmdr Command Server Logic Source: https://eryn.io/Cmdr/guide/Commands Provides the server-side implementation for a Cmdr command. This function is executed when the command is run and receives the CommandContext along with the parsed arguments. It handles the actual logic, such as teleporting players. ```lua -- TeleportServer.lua -- These arguments are guaranteed to exist and be correctly typed. return function (context, fromPlayers, toPlayer) if toPlayer.Character and toPlayer:FindFirstChild("HumanoidRootPart") then local position = toPlayer.Character.HumanoidRootPart.CFrame for _, player in ipairs(fromPlayers) do if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then player.Character.HumanoidRootPart.CFrame = position end end return "Teleported players." end return "Target player has no character." end ``` -------------------------------- ### Cmdr Util Static Functions Source: https://eryn.io/Cmdr/api/Util Documentation for static utility functions within the Cmdr library, including data transformation and manipulation methods. ```APIDOC Util.MakeDictionary(array: array) → dictionary Accepts an array and flips it into a dictionary, its values becoming keys in the dictionary with the value of `true`. Parameters: array: array (Required) Returns: dictionary Util.Map( array: array, mapper: function( value: T, index: number ) → U ) → array Maps values from one array to a new array. Passes each value through the given callback and uses its return value in the same position in the new array. Parameters: array: array (Required) mapper: function(value: T, index: number) → U (Required) Parameters: value: T (Required) index: number (Required) Returns: U Returns: array Util.Each( mapper: function(value: T) → U, ...: T ) → U... Maps arguments #2-n through callback and returns all values as tuple. Parameters: mapper: function(value: T) → U (Required) Parameters: value: T (Required) Returns: U ...: T (Required) Returns: U... ``` -------------------------------- ### CmdrClient Configuration API Source: https://eryn.io/Cmdr/api/CmdrClient Provides methods to configure various behaviors of the Cmdr client, including enabling/disabling features like mouse unlocking on activation and hiding the window when focus is lost. Some settings may require specific versions (e.g., v1.6.0+). ```APIDOC CmdrClient: SetMashToEnable(isEnabled: boolean) → void Parameters: isEnabled: boolean - Whether to enable or disable the feature. Returns: void SetActivationUnlocksMouse(isEnabled: boolean) → void Parameters: isEnabled: boolean - Whether to enable or disable mouse unlocking on activation. Returns: void SetHideOnLostFocus(isEnabled: boolean) → void Parameters: isEnabled: boolean - Whether to enable or disable hiding the window on lost focus. Returns: void ``` -------------------------------- ### Cmdr Alias with Command Description Source: https://eryn.io/Cmdr/guide/MetaCommands Demonstrates how to provide a description for the alias command itself, improving discoverability and usability. The description is placed before the alias name, enclosed in quotes. ```Cmdr alias "goodbye|Kills a player." kill $1{player|Player|The player you want to kill.} ``` -------------------------------- ### ArgumentContext API Documentation Source: https://eryn.io/Cmdr/api/ArgumentContext Details the properties and instance methods of the ArgumentContext class in Cmdr. This context provides information about command arguments, including their name, type, value, and executor. ```APIDOC ArgumentContext: Properties: Command: The command associated with this argument context. Name: The name of the argument. Type: The data type of the argument. Required: Indicates if the argument is required. Executor: The entity that executed the command. RawValue: The raw, untransformed value of the argument. RawSegments: The raw segments of the argument value. Prefix: The prefix used for the argument. Instance Methods: GetValue(): Retrieves the value of the argument. Returns: The argument's value. GetTransformedValue(segment): Parameters: segment: The segment to transform. Returns: The transformed value of the argument segment. ``` -------------------------------- ### CmdrClient Properties Source: https://eryn.io/Cmdr/api/CmdrClient Provides access to the CmdrClient's registry, dispatcher, utility functions, and configuration properties like enabled status, place name, and activation keys. ```APIDOC CmdrClient.Registry: `[Registry](https://eryn.io/Cmdr/api/Registry.html#registry)` read only Refers to the current command Registry. CmdrClient.Dispatcher: `[Dispatcher](https://eryn.io/Cmdr/api/Dispatcher.html#dispatcher)` read only Refers to the current command Dispatcher. CmdrClient.Util: `[Util](https://eryn.io/Cmdr/api/Util.html#util)` read only Refers to a table containing many useful utility functions. CmdrClient.Enabled: `boolean` read only CmdrClient.PlaceName: `string` read only CmdrClient.ActivationKeys: `dictionary` read only ``` -------------------------------- ### Util.MakeFuzzyFinder Source: https://eryn.io/Cmdr/api/Util Creates a fuzzy finder function from a set of strings, instances, enum items, or named objects. The returned function takes a text input and optionally returns only the first match. ```APIDOC Util.MakeFuzzyFinder: Description: Makes a fuzzy finder for the given set or container. You can pass an array of strings, array of instances, array of EnumItems, array of dictionaries with a Name key or an instance (in which case its children will be used). Parameters: set: array | array | array | array | Instance - The set or container to create the fuzzy finder from. Returns: function(text: string, returnFirst?: boolean?) -> any - A function that takes a string and optionally a boolean to return the first match, returning matching objects. ``` -------------------------------- ### Cmdr Registry API Documentation Source: https://eryn.io/Cmdr/api/Registry Documentation for the Cmdr Registry class, which handles the registration of commands, types, and hooks. It includes details on type definitions, properties, and instance methods for managing these registrations. ```APIDOC Registry: Handles registering commands, types, and hooks. Exists on both client and server. Types: TypeDefinition CommandArgument CommandDefinition Properties: Cmdr: The Cmdr instance associated with the registry. Instance Methods: RegisterTypesIn(container): Registers all types found within the provided container. Parameters: container: The container object to scan for types. Returns: None RegisterType(name, typeDefinition): Registers a single type with a given name. Parameters: name: The name to associate with the type definition. typeDefinition: The definition of the type to register. Returns: None RegisterTypePrefix(name, union): Registers a type alias for a union of types, using a prefix for naming. Parameters: name: The prefix name for the type alias. union: The union of types to register under the alias. Returns: None RegisterTypeAlias(name, union): Registers a type alias for a union of types. Parameters: name: The name of the type alias. union: The union of types to register under the alias. Returns: None GetType(name): Retrieves the type definition associated with a given name. Parameters: name: The name of the type to retrieve. Returns: The registered type definition. GetTypeName(name): Retrieves the registered name for a given type. Parameters: name: The type to find the registered name for. Returns: The registered name of the type. RegisterHooksIn(container): Registers all hooks found within the provided container. Parameters: container: The container object to scan for hooks. Returns: None RegisterCommandsIn(container): Registers all commands found within the provided container. Parameters: container: The container object to scan for commands. Returns: None RegisterCommand(name, commandDefinition): Registers a single command with a given name. Parameters: name: The name to associate with the command definition. commandDefinition: The definition of the command to register. Returns: None RegisterDefaultCommands(): Registers a set of default commands. Returns: None GetCommand(name): Retrieves the command definition associated with a given name. Parameters: name: The name of the command to retrieve. Returns: The registered command definition. GetCommands(): Retrieves all registered commands. Returns: A collection of all registered command definitions. GetCommandNames(): Retrieves the names of all registered commands. Returns: A list of registered command names. RegisterHook(name, hook): Registers a single hook with a given name. Parameters: name: The name to associate with the hook. hook: The hook function to register. Returns: None GetStore(): Retrieves the data store associated with the registry. Returns: The registry's data store. ``` -------------------------------- ### Cmdr Bind Command Usage Source: https://eryn.io/Cmdr/guide/MetaCommands Explains the basic usage of the 'bind' command to associate a command string with an event, such as user input. It also mentions the ability to bind to player chat by prefixing the first argument with '@' and network events with '!'. ```Cmdr CmdrClient:Run("bind", keyCode.Name, "cast_ability", abilityId) ``` -------------------------------- ### CmdrClient Window Management API Source: https://eryn.io/Cmdr/api/CmdrClient Provides methods to control the visibility and state of the Cmdr window. Includes functions to explicitly show, hide, or toggle the window's visibility. These methods are effective only if Cmdr is enabled. ```APIDOC CmdrClient: Show(void) Shows the Cmdr window explicitly. Does not do anything if Cmdr is not enabled. Returns: void Hide(void) Hides the Cmdr window. Returns: void Toggle(void) Toggles visibility of the Cmdr window. Will not show if Cmdr is not enabled. Returns: void ``` -------------------------------- ### Register BeforeRun Hook Source: https://eryn.io/Cmdr/guide/Hooks Registers a BeforeRun hook to intercept command execution, useful for permissions. If a string is returned, it replaces the command's output. ```lua return function (registry) registry:RegisterHook("BeforeRun", function(context) if context.Group == "DefaultAdmin" and context.Executor.UserId ~= game.CreatorId then return "You don't have permission to run this command" end end) end ``` -------------------------------- ### Cmdr Util: EmulateTabstops Source: https://eryn.io/Cmdr/api/Util Converts tab characters ('\t') in a string into spaces based on a specified tab width, emulating tab stop behavior. ```APIDOC Util.EmulateTabstops( text: string, tabWidth: number ) → string Parameters: - text: The input string potentially containing tab characters. - tabWidth: The number of spaces to represent a single tab character. Returns: A string with tab characters replaced by spaces. ``` -------------------------------- ### Define a Cmdr Command Source: https://eryn.io/Cmdr/guide/Commands Defines the metadata for a custom command, including its name, aliases, description, group, and arguments. This definition is used by Cmdr to register and understand the command's structure. ```lua -- Teleport.lua, inside your commands folder as defined above. return { Name = "teleport"; Aliases = {"tp"}; Description = "Teleports a player or set of players to one target."; Group = "Admin"; Args = { { Type = "players"; Name = "from"; Description = "The players to teleport"; }, { Type = "player"; Name = "to"; Description = "The player to teleport to" } }; } ``` -------------------------------- ### Cmdr Argument Value Operators Source: https://eryn.io/Cmdr/guide/Commands Shorthand operators for specifying argument values, providing defaults, random selections, or all possible values. ```lua -- Example usage with the 'players' type: -- kill . -- Kills the player running the command -- kill ? -- Kills a random player -- kill * -- Kills all players -- kill ** -- Kills all players except the one running the command -- kill ?3 -- Kills 3 random players -- kill \* -- Kills a player literally named '*' ``` -------------------------------- ### Cmdr Client-Side Command Execution Source: https://eryn.io/Cmdr/guide/Commands Enables commands to run exclusively on the client or both client and server. A 'ClientRun' function can be added to the command definition for client-side execution. ```lua Cmdr:RegisterCommand(Command.new("ClientOnlyCommand", { ClientRun = function(context) -- This function runs on the client. -- If it returns a string, the command runs entirely on the client. return "Client execution complete." end })) Cmdr:RegisterCommand(Command.new("ClientServerCommand", { ClientRun = function(context) -- If this returns nil, the server implementation will run. end, Server = function(context) -- Server implementation end })) ``` -------------------------------- ### Cmdr Prefixed Union Types Source: https://eryn.io/Cmdr/guide/Commands Prefixed union types allow arguments to accept different types based on a prefix. This enables flexible argument parsing, such as selecting players by team name using a '%' prefix. Multiple prefixed types can be chained. ```APIDOC Prefixed Union Types: Description: Allows arguments to accept different types based on a prefix. Syntax: Type = " ..." Example: Type = "string # number @ player % team" Automatic Prefixed Union Types: Type | Union ----------|-------------------------- players | players % teamPlayers playerId | playerId # integer playerIds | playerIds # integers brickColor| brickColor % teamColor brickColors| brickColors % teamColors color3 | color3 # hexColor3 ! brickColor3 color3s | color3s # hexColor3s ! brickColor3s ``` -------------------------------- ### Cmdr Util: RunEmbeddedCommands Source: https://eryn.io/Cmdr/api/Util Parses and executes embedded commands within a given command string using the provided dispatcher, returning the output of the executed commands. ```APIDOC Util.RunEmbeddedCommands( dispatcher: Dispatcher, commandString: string ) → string Parameters: - dispatcher: The Dispatcher instance used to evaluate and run commands. - commandString: The string containing embedded commands. Returns: The string output from evaluating and running the embedded commands. ``` -------------------------------- ### Register Custom Integer Type Source: https://eryn.io/Cmdr/guide/Types Demonstrates how to register a custom 'integer' type with validation and transformation logic in Cmdr. This allows for more specific input handling for integer arguments. ```lua local intType = { Transform = function (text) return tonumber(text) end; Validate = function (value) return value ~= nil and value == math.floor(value), "Only whole numbers are valid." end; Parse = function (value) return value end } return function (registry) registry:RegisterType("integer", intType) end ``` -------------------------------- ### Cmdr Bind to Player Chat Source: https://eryn.io/Cmdr/guide/MetaCommands Shows how to bind a command to a specific player's chat events. The command string will execute when the specified player chats, and the chat text can be accessed using $1. ```Cmdr bind @ "" ``` -------------------------------- ### Cmdr Util: MakeSequenceType Source: https://eryn.io/Cmdr/api/Util Creates a type that handles sequences (like Vector3 or Color3) with customizable parsing and transformation. It supports delimiters like ',' or whitespace and can use a constructor function or a parse function. ```APIDOC Util.MakeSequenceType(options: { TransformEach?: function(value: any, index: number) -> any, ValidateEach?: function(value: any, index: number) -> boolean | string, Parse?: function(values: array) -> any, Constructor?: function(...args: any) -> any }) → void Parameters: - options: A table containing configuration for sequence parsing. - TransformEach: A function to transform each member of the sequence. - ValidateEach: A function to validate each member of the sequence. - Parse: A function to parse all values into a single type. - Constructor: A function to construct the object using unpacked values. Returns: void ``` -------------------------------- ### Cmdr Default Command Registration Source: https://eryn.io/Cmdr/guide/Commands Registers a predefined set of default commands provided by Cmdr. This can be done for all default commands or a filtered subset. ```lua -- Register all default commands Cmdr:RegisterDefaultCommands() -- Register only 'Help' and 'DefaultUtil' groups Cmdr:RegisterDefaultCommands({"Help", "DefaultUtil"}) -- Register commands with names shorter than 6 characters Cmdr:RegisterDefaultCommands(function(cmd) return #cmd.Name < 6 end) ``` -------------------------------- ### Cmdr Util: SubstituteArgs Source: https://eryn.io/Cmdr/api/Util Replaces argument placeholders (e.g., $1, $2) in a string with corresponding values provided via a table or a function. ```APIDOC Util.SubstituteArgs( text: string, replace: array | dictionary | function(var: string) → string ) → string Parameters: - text: The string containing arguments to be replaced. - replace: A table or function used for replacement. Can be an array of strings, a dictionary mapping placeholders to values, or a function that returns the replacement value for a given placeholder. Returns: A string with the arguments replaced. ``` -------------------------------- ### Util.SplitString Source: https://eryn.io/Cmdr/api/Util Splits a string by spaces, with special handling for double-quoted sequences which are treated as single values. An optional maximum number of splits can be specified. ```APIDOC Util.SplitString: Description: Splits a string by spaces, but taking double-quoted sequences into account which will be treated as a single value. Parameters: text: string - The string to split. max: number? - An optional maximum number of splits to perform. Returns: array - An array of strings resulting from the split. ``` -------------------------------- ### Cmdr CommandContext Properties Source: https://eryn.io/Cmdr/api/CommandContext Details the properties available within the CommandContext object, providing access to command-related information. ```APIDOC Cmdr: Description: The Cmdr instance that dispatched the command. Dispatcher: Description: The Dispatcher instance responsible for command routing. Name: Description: The name of the command being executed. Alias: Description: The alias used to invoke the command, if any. RawText: Description: The raw text input for the command. Group: Description: The group the command belongs to. State: Description: The current state of the command execution. Aliases: Description: A list of all aliases for the command. Description: Description: The descriptive text for the command. Executor: Description: The function or method that executes the command. RawArguments: Description: The raw, unparsed arguments passed to the command. Arguments: Description: The parsed arguments for the command. Response: Description: The response object associated with the command execution. ``` -------------------------------- ### Cmdr Unbind Command Source: https://eryn.io/Cmdr/guide/MetaCommands Introduces the 'unbind' command, which is used to remove previously established bindings created with the 'bind' command. ```Cmdr unbind ``` -------------------------------- ### Create Enum Type Source: https://eryn.io/Cmdr/guide/Types Demonstrates how to create a custom Enum type using Cmdr's utility function. This type restricts command arguments to a predefined list of strings, ensuring valid input. ```lua return function (registry) registry:RegisterType("place", registry.Cmdr.Util.MakeEnumType("Place", {"World 1", "World 2", "World 3", "Final World"})) end ``` -------------------------------- ### CmdrClient Event Handling API Source: https://eryn.io/Cmdr/api/CmdrClient Allows for registering event handlers for specific events within the Cmdr client. It takes an event name (string) and a handler function as parameters. ```APIDOC CmdrClient: HandleEvent( event: string, handler: function(...?: any?) → void ) → void Parameters: event: string - The name of the event to handle. handler: function(...?: any?) → void - The function to execute when the event is triggered. Returns: void ``` -------------------------------- ### Util.SplitStringSimple Source: https://eryn.io/Cmdr/api/Util Splits a given string into an array of substrings based on a specified separator. This is a straightforward string splitting utility. ```APIDOC Util.SplitStringSimple: Description: Splits a string into an array split by the given separator. Parameters: text: string - The string to be split. separator: string - The delimiter to split the string by. Returns: array - An array of substrings. ``` -------------------------------- ### Util.TrimString Source: https://eryn.io/Cmdr/api/Util Removes leading and trailing whitespace from a string. ```APIDOC Util.TrimString: Description: Trims whitespace from both sides of a string. Parameters: text: string - The string to trim. Returns: string - The trimmed string. ``` -------------------------------- ### Handle Network Events with CmdrClient Source: https://eryn.io/Cmdr/guide/NetworkEventHandlers Demonstrates how to set a custom handler for the 'Message' event using CmdrClient. This allows you to define specific client-side behavior when a 'Message' event is broadcast, overriding the default system chat message. ```lua CmdrClient:HandleEvent("Message", function (text, player) print("Announcement from", player.Name, text) end) ``` -------------------------------- ### Register AfterRun Hook Source: https://eryn.io/Cmdr/guide/Hooks Registers an AfterRun hook to execute after a command. It can be used for logging or modifying the command's response by returning a string. ```lua Cmdr.Registry:RegisterHook("AfterRun", function(context) print(context.Response) -- see the actual response from the command execution return "Returning a string from this hook replaces the response message with this text" end) ``` -------------------------------- ### Cmdr Util: MakeListableType Source: https://eryn.io/Cmdr/api/Util Converts a singular type definition into a plural (listable) type definition. It can optionally override properties of the resulting type. ```APIDOC Util.MakeListableType( type: TypeDefinition, override?: dictionary ) → TypeDefinition Parameters: - type: The TypeDefinition to make listable. - override: An optional dictionary to override properties of the listable type. Returns: A new TypeDefinition representing the listable type. ``` -------------------------------- ### Cmdr Command Data Function Source: https://eryn.io/Cmdr/guide/Commands Defines a 'Data' function within a Cmdr command to gather information from the client before execution. The returned data is accessible via context:GetData() in the command implementation. ```lua Cmdr:RegisterCommand(Command.new("MyCommand", { Data = function(context) -- Gather data from the client, e.g., player's mouse position local mousePosition = LocalPlayer:GetMouse().Hit.Position return mousePosition end, Run = function(context) local data = context:GetData() -- Access the gathered data (Vector3) -- Command implementation using the data end })) ```