Skip to main content

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

ValueTypeDescription
namestringUnique 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 cj and heal cj are 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.