Skip to content

Custom Slash Commands

rune.command.add("greet", function(args)
rune.send("say Hello, " .. (args ~= "" and args or "everyone") .. "!")
end, "Greet someone")

/greet Bob now works, appears in /help, and shows up in the / picker with its description. All of that is generated from the registry, so the listings never drift from what is actually registered.

rune.command.add(name, handler, description?, opts?)

The handler is a function; it receives everything after /name as a single string ("" when there are no arguments). The command name doubles as its registry name.

Commands take the common option group. The command name doubles as the registry name, so re-adding a name replaces it.

A command with subcommands:

rune.command.add("pather", function(args)
local sub, rest = args:match("^(%S*)%s*(.*)$")
if sub == "go" then
pather.go(rest)
elseif sub == "stop" then
pather.stop()
else
rune.echo("[Usage] /pather go <place> | /pather stop")
end
end, "Walk saved paths")

Overriding a built-in. Re-adding a name replaces it, so you can wrap:

local quit = rune.command.get("quit")
rune.command.add("quit", function(args)
rune.send("save")
quit(args)
end, "Save, then exit")

By name: rune.command.enable/disable/remove(name), plus rune.command.get(name) for the raw handler — full signatures in the rune.command reference. In the client, /help lists every command, including script-added ones, with descriptions and sources.

  • Commands are quarantined individually: a broken handler can never take down input handling. A disabled command still consumes its input (with an error message).
  • Unknown commands report [Error] Unknown command: /x and are never sent to the server. Use /raw /text if a game actually wants a literal slash.

Related: rune.command reference, Aliases, Built-in slash commands