rune.command
Slash commands add /name verbs to the input line. For a
task-oriented introduction, see Slash Commands.
Quick reference
Section titled “Quick reference”rune.command.add(name, handler, description?, opts?) -- register /namerune.command.remove(name) -- unregister; true if it existedrune.command.get(name) -- the command's handle, or nilrune.command.enable(name) -- re-enable (also recovers from quarantine)rune.command.disable(name) -- disable without unregisteringrune.command.list() -- array of {name, description, enabled, group, source}add returns a handle; opts accepts
group from the common options. The command
is its own name, so a name in opts is
ignored with a notice.
To wrap a built-in, capture its action before replacing it:
local quit = assert(rune.command.get("quit")):action()rune.command.add("quit", function(args) rune.send("save") quit(args)end, "Save, then exit")rune.command.add
Section titled “rune.command.add”rune.command.add(name, handler, description?, opts?) -> handlename(string) — a non-empty, single-word command name without the slash. Re-adding the same name replaces the old handler (upsert).handler(function) —function(args);argsis everything after/nameas a single string (""when there are no arguments).description(string, optional) — shown in/helpand the/command picker.opts(table, optional) —{group = "..."}.
rune.command.add("greet", function(args) rune.send("say Hello, " .. (args ~= "" and args or "everyone") .. "!")end, "Greet someone")/help and the / picker are generated from the registry, so
user-added commands appear in both automatically.
Each command is quarantined individually —
a command that throws three times in a row is disabled with a notice,
and input handling keeps working. Fix the error and
rune.command.enable(name) (or /reload) to recover.
Managing
Section titled “Managing”Standard registry management applies:
rune.command.get/enable/disable/remove(name), .list(). See
Registries. /help lists everything.
Related: Slash Commands guide · rune.alias · rune.bind · Slash Commands reference