# Run commands

> Run your game's registered Cmdr commands on live servers from the browser, with validation, server routing and a full history.

Bloxlytics can run the [Cmdr](https://eryn.io/Cmdr/) commands your game already has, on live game servers, from the **Macro Runner** page. It doesn't add a scripting backdoor: the [Cmdr bridge](https://docs.bloxlytics.app/sdk/cmdr-bridge) in your game only runs commands that are registered with Cmdr, through Cmdr's own dispatcher, so argument types, arity and your `BeforeRun` hooks apply exactly as they do in-game. It never evaluates source code.

## What you need

- The [Cmdr bridge](https://docs.bloxlytics.app/sdk/cmdr-bridge) installed and running in your game. Game servers long-poll Bloxlytics over HTTPS; Bloxlytics never opens a connection into Roblox.
- The **Cmdr bridge** switch on in the project's SDK configuration. When it's off, servers still register but nothing is dispatched, and requests fail with "The command bridge is disabled in project settings."
- At least one live server running the bridge. The **Macro Runner** header shows how many are online.
- The right permissions:

| Permission | Allows | Default roles |
| --- | --- | --- |
| `commands.view` — View registered Cmdr commands and history | Opening **Macro Runner**, the **Commands** and **History** tabs, validating command lines | Owner, Admin, Developer |
| `commands.execute` — Execute Cmdr commands | Running commands from the **Console**, the player profile and macros | Owner, Admin, Developer |

The API checks these on every request. See [Roles and permissions](https://docs.bloxlytics.app/workspaces/roles-and-permissions) to grant them to other roles.

## Command discovery

You don't define commands in Bloxlytics. When a game server starts, its bridge sends a registration ("hello") listing every command registered with Cmdr: name, aliases, description, group and arguments (name, type, description, whether it's optional, and its default). It re-sends this every 5 minutes while the server runs.

Bloxlytics keeps the most recent definition of each command per project. Commands that no server has reported for 24 hours are hidden, so a command you remove from the game drops out by itself.

The **Commands** tab lists them, searchable by name, alias, description or group:

| Column | Shows |
| --- | --- |
| **Command** | Name and aliases |
| **Description** | Cmdr's description |
| **Arguments** | The signature: `<name: type>` for required arguments, `[name: type]` for optional ones, with defaults |
| **Group** | The command's Cmdr group |
| **Availability** | **Available**, or **Not enabled for the platform** when the game's bridge `AllowedGroups` doesn't include the command's group |

If the list is empty, no server with the bridge has started since it was installed, or none has reported in the last 24 hours.

### Registration limits

| Item | Limit |
| --- | --- |
| Commands per server | 500 |
| Aliases per command | 20 |
| Arguments per command | 32 |
| Command or argument name | 64 characters |
| Description | 512 characters (argument descriptions 256) |

## The console

Open **Macro Runner → Console**.

**1. Pick a server**

The server picker starts on **Automatic**. Open it to choose a specific live server instead. Each server shows its short job id, player count and tags (set in-game with `Analytics:SetServerTag`), plus:

- a person icon when you're in that server, so commands run as your player;
- a lock icon when the server only runs commands as a team member who is in it;
- a **Studio** badge for Studio sessions.

**2. Type the command**

Type the command line in the command field, using Cmdr's syntax: arguments separated by spaces, double quotes to group words (`announce "Server restarting soon"`). As you type the first word, up to eight matching commands are suggested; use the arrow keys and **Tab** or **Enter** to accept one, **Esc** to dismiss. Commands that aren't enabled for the platform are greyed out and marked "Not enabled".

Once the command is recognised, its signature appears below the field with the argument you're typing highlighted.

**3. Run it**

Press **Enter** or select **Run**. The line appears in the log with its status, then the command's output or error when the game answers.

Beside the console, **Recent commands** lists the last 15 commands anyone on the team ran, with who ran them, when, whether they came from a macro, and the result. It refreshes every 10 seconds.

You can also run a command for one player from their [profile](https://docs.bloxlytics.app/operations/player-lookup): **Actions → Execute command**, or the **Commands** tab. Choosing a command whose first argument is a player fills in that player for you, and the command is routed to that player's server.

## Validation

Before a command is queued, Bloxlytics checks its structure against the reported definitions — in the browser as you type, and again on the server:

- the first word must be a registered command name or alias (case doesn't matter);
- the command must be enabled for the platform;
- every required argument must be present (optional arguments, ones with defaults and ones Cmdr resolves at runtime don't count);
- there can't be more arguments than the command defines, unless the last one is a string, because Cmdr joins trailing words into a final string argument;
- `number` and `integer` arguments (and their plural forms, comma-separated) must be numbers, integers must be whole, and `boolean` arguments must be one of `true`, `false`, `yes`, `no`, `on`, `off`, `1` or `0`.

Other types — players, teams, your own custom types — are validated by Cmdr in the game, and a mistake comes back as the command's error. A command line can be up to 500 characters.

## Where a command runs

Bloxlytics chooses one live server running the bridge, in this order:

1. The server you picked.
2. If the command targets a player (from their profile), the server that player is in.
3. The server you're playing in, if your Roblox account is in one.
4. Otherwise, the least busy live server.

**Automatic** never picks a Studio session — choose one explicitly to run commands there. If only Studio sessions are online you're told "Only Studio sessions are online. Choose one explicitly to run commands there." A server you picked that has gone offline gives "That server is offline or doesn't run the bridge."

> **Warning:** A command runs on **one** server. A command that changes game state, such as giving currency, only affects players and data on that server. If the command names a player, run it from that player's profile or pick the server they're in.

## Who a command runs as

You sign in to Bloxlytics with Roblox, so your Roblox account is verified. That decides how the game sees your command:

- **You're in the target server**: the bridge runs the command *as your player*. Your `BeforeRun` hooks see `context.Executor` as your Player and judge you exactly as if you'd typed the command in-game. No hook changes are needed.
- **You're not in it**: the command runs in the *system context* — `Executor` is `nil` and `context.Data.Bloxlytics` holds your Bloxlytics id, name, role and the execution id. Use `CmdrBridge.IsPlatformContext(context)` in a hook to allow these; see [Cmdr bridge security](https://docs.bloxlytics.app/sdk/cmdr-bridge/security).

A server whose bridge is started with `AllowSystemCommands = false` refuses system-context commands. Sending one fails with "That server only runs commands as a player who is in it. Join it with your linked Roblox account, or pick the server you're in." **Automatic** skips such servers unless you're in one.

The line under the console summarises this for you, and every command in the log and history has an icon showing whether it ran as a player or in the system context.

## Per-role Cmdr groups

On top of the game's own `AllowedGroups` and hooks, an owner or admin can restrict which Cmdr groups each role may run from Bloxlytics. On the project's **SDK** page, under **Configuration**, **Cmdr groups per role** has a list for **Owner**, **Admin** and **Developer**. Leave a list empty to allow every group the bridge permits. Analysts and viewers who've been granted command access use the developer list.

A command outside your role's list is refused before it's sent, for example: `Your role (developer) may only run commands in these Cmdr groups: Admin. "kick" is in "Moderation".`

## Results and statuses

Each command becomes an execution that moves through these states:

| Status | Meaning |
| --- | --- |
| **Queued** | Waiting for the chosen server to pick it up. |
| **Running** | Delivered to the server. |
| **Success** | The command ran. The output is Cmdr's replies plus the command's return value, or "Command executed." |
| **Error** | Cmdr, a `BeforeRun` hook (reported as "Rejected by BeforeRun hook: …"), the bridge or the command itself refused or failed. The error is shown. |
| **Timed out** | No server picked it up, or it didn't report back, in time. |

Commands expire 60 seconds after they're queued. A command still queued after about 70 seconds, or delivered but without a result after 2 minutes, is marked **Timed out**. The bridge refuses expired commands and command ids it has already run, and Bloxlytics accepts exactly one result per command, only from the server it was delivered to. Output and errors are kept up to 4,000 characters.

> **Note:** A command that times out may still have run if the server ran it but couldn't report back. Check the game before running it again.

Each person can run up to 30 commands a minute in a project.

## History

**Macro Runner → History** has a **Command history** table of the last 100 commands sent to game servers — from the console, from macros (marked "From a macro"), from player actions, and kicks and warnings (marked with their kind). Select a row for the full record: the command, status, who ran it, the server's full job id, **Ran as** (player or system), duration, when it was queued and completed, and the full output or error.

A player's **Commands** tab lists the commands that targeted that player.

Every command is also written to the [audit log](https://docs.bloxlytics.app/workspaces/audit-log) as "Executed a command", with the command line and its target server or player.

## Troubleshooting

**No game servers with the Cmdr bridge are online**

Commands can only run while at least one live server runs the bridge. Check the server's output for `[Bloxlytics bridge]` warnings — a wrong bridge key, a missing **Allow HTTP Requests** setting or an unreachable API URL stop it from registering. See [Cmdr bridge](https://docs.bloxlytics.app/sdk/cmdr-bridge).

**A command shows Not enabled for the platform**

The game's bridge `AllowedGroups` doesn't include that command's Cmdr group. Add the group in-game if you want it available from Bloxlytics.

**A command fails with Rejected by BeforeRun hook**

Your game's hook refused it. If the command ran in the system context, your hook probably requires a player; either join the server so it runs as you, or allow `CmdrBridge.IsPlatformContext(context)` in the hook.

**The Run button is disabled**

Hover it for the reason: your role lacks `commands.execute`, or no live server with the bridge is online.

To run several commands in order, with variables and delays, save them as a [macro](https://docs.bloxlytics.app/operations/macros).
