Command handlers
Register a command with server.command(name, handler). The handler receives a verified Player
and parsed arguments. Command names use lowercase letters, digits, hyphens and underscores, up to
32 characters.
Parameters
| Value | Type | Description |
|---|---|---|
name | string | Unique command name, without /. |
handler | (context) => void | Promise<void> | Receives { player, arguments }. |
Example
server.command("heal", async ({ player, arguments: args }) => {
// Apply authoritative state through the server API.
server.emitClientEvent(player, "ui.notice", `Heal requested: ${args[0] ?? "self"}`);
});
Notes
- Both
/heal cjandheal cjare accepted by the command parser. - Arguments are capped at 128 characters and quoted arguments may contain whitespace.
- Duplicate or invalid names are rejected; unauthenticated dispatch never reaches the handler.