Skip to main content

Dispatcher

The dispatcher handles parsing, validating, and evaluating commands.

Properties

Cmdr

This item is read only and cannot be modified. Read Only
Dispatcher.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.

Registry

This item is read only and cannot be modified. Read Only
Dispatcher.Registry: Registry

Refers to the command Registry.

Functions

EvaluateAndRun

Dispatcher:EvaluateAndRun(
textstring,
executorPlayer?,
options{
Dataany?,
IsHumanboolean?,
}?
) → string

Runs a command as the given player. Executor is optional when running on the client. If options.Data is given, it will be available on the server with CommandContext.GetData If options.IsHuman is true and this function is called on the client, then the text will be inserted into the window history.

SendEvent

Dispatcher:SendEvent(
playerPlayer,
eventstring,
...any
) → ()

Sends an event to a player.

BroadcastEvent

Dispatcher:BroadcastEvent(
eventstring,
...any
) → ()

Broadcasts an event to all clients.

Run

This item only works when running on the client. Client
Dispatcher:Run(...any) → string

Invokes a command programmatically as the local player. Accepts a variable number of arguments, which are all joined with spaces before being run; the command should be the first argument. This function will raise an error if any validations occur, since it's only for hard-coded (or generated) commands.

RunBeforeCommandRegisterHooks

Dispatcher:RunBeforeCommandRegisterHooks(
playerPlayer?--

The player to run the hook for. This argument is required when the method is called from the server, and must be `nil`` on the client.

) → ()

Runs all BeforeCommandRegister Hooks on the client.

GetHistory

This item only works when running on the client. Client
Dispatcher:GetHistory() → {string}

Returns an array of the user's command history. Most recent commands are inserted at the end of the array.

Show raw api
{
    "functions": [
        {
            "name": "Evaluate",
            "desc": "Takes in raw command information and generates a command out of it.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "executor",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "allowIncompleteArguments",
                    "desc": "When true, will ignore errors about arguments missing so we can parse live as the user types",
                    "lua_type": "boolean?"
                },
                {
                    "name": "data",
                    "desc": "Used for special networked Data about the command gathered on the client, purely optional.",
                    "lua_type": "any?\n"
                }
            ],
            "returns": [
                {
                    "desc": "If unsuccessful, returns false and the error text",
                    "lua_type": "(CommandContext) | (false, string)"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 59,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "EvaluateAndRun",
            "desc": "Runs a command as the given player. Executor is optional when running on the client.\nIf `options.Data` is given, it will be available on the server with CommandContext.GetData\nIf `options.IsHuman` is true and this function is called on the client, then the `text` will be inserted into the window history.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "executor",
                    "desc": "",
                    "lua_type": "Player?"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "{\n\t\tData: any?,\n\t\tIsHuman: boolean?,\n\t}?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 108,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "Send",
            "desc": "Send text as the local user to remote server to be evaluated there.",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "any?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "private": true,
            "source": {
                "line": 155,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "SendEvent",
            "desc": "Sends an event to a player.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "event",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 164,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "BroadcastEvent",
            "desc": "Broadcasts an event to all clients.",
            "params": [
                {
                    "name": "event",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 183,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "Run",
            "desc": "Invokes a command programmatically as the local player.\nAccepts a variable number of arguments, which are all joined with spaces before being run; the command should be the first argument.\nThis function will raise an error if any validations occur, since it's only for hard-coded (or generated) commands.",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string\n"
                }
            ],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "source": {
                "line": 197,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "RunGuards",
            "desc": "Runs command-specific guard methods.",
            "params": [
                {
                    "name": "commandContext",
                    "desc": "",
                    "lua_type": "CommandContext"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "ArgumentContext..."
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?\n"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 224,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "RunHooks",
            "desc": "Runs hooks matching the specified hook name.",
            "params": [
                {
                    "name": "hookName",
                    "desc": "",
                    "lua_type": "HookType"
                },
                {
                    "name": "commandContext",
                    "desc": "",
                    "lua_type": "CommandContext"
                },
                {
                    "name": "passExactValue",
                    "desc": "",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [
                {
                    "desc": "nil for success, string for cancellation.",
                    "lua_type": "string?"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 260,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "_runBeforeCommandRegisterHookForCommand",
            "desc": "Runs all BeforeCommandRegister Hooks on the specified CommandDefinition.",
            "params": [
                {
                    "name": "commandObject",
                    "desc": "",
                    "lua_type": "CommandDefinition"
                }
            ],
            "returns": [
                {
                    "desc": "nil for success, string for cancellation.",
                    "lua_type": "string?"
                }
            ],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "private": true,
            "source": {
                "line": 310,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "RunBeforeCommandRegisterHooks",
            "desc": "Runs all BeforeCommandRegister Hooks on the client.",
            "params": [
                {
                    "name": "player",
                    "desc": "The player to run the hook for. This argument is required when the method is called from the server, and must be `nil`` on the client.",
                    "lua_type": "Player?"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 338,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "GetHistory",
            "desc": "Returns an array of the user's command history. Most recent commands are inserted at the end of the array.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ string }\n"
                }
            ],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "source": {
                "line": 361,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "_pushHistory",
            "desc": "Inserts the string into the window history",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "realm": [
                "Client"
            ],
            "private": true,
            "source": {
                "line": 373,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "Cmdr",
            "desc": "A reference to Cmdr. This may either be the server or client version of Cmdr depending on where the code is running.",
            "lua_type": "Cmdr | CmdrClient",
            "readonly": true,
            "source": {
                "line": 32,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        },
        {
            "name": "Registry",
            "desc": "Refers to the command Registry.",
            "lua_type": "Registry",
            "readonly": true,
            "source": {
                "line": 42,
                "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
            }
        }
    ],
    "types": [],
    "name": "Dispatcher",
    "desc": "The dispatcher handles parsing, validating, and evaluating commands.",
    "source": {
        "line": 23,
        "path": "Cmdr/CmdrClient/Shared/Dispatcher.luau"
    }
}