Registering commands
swizzin.command(name, fn, description?)Adds /name. The name is 1 to 32 letters, digits or underscores. The function receives ctx and args.
ctx field |
Meaning |
|---|---|
network, network_name |
Where the command was typed |
me |
Your nickname on that network |
target |
The active channel or conversation (absent in a server window) |
text |
The raw text after the command |
command |
The command name |
args is a read-only list of the whitespace-separated words of text (at most 50).
Example
Section titled “Example”--! name: Shout--! api: 1--! permissions: sendswizzin.command("shout", function(ctx, args) if ctx.target ~= nil then swizzin.send(ctx.target, string.upper(ctx.text)) endend, "Send your text in capitals")Typing /shout hello in a channel sends HELLO to it.
What cannot be registered
Section titled “What cannot be registered”- Built-in commands.
- The names
theme,channels,scriptsandscript. - A name already provided by another script.
Precedence
Section titled “Precedence”Protected command, then built-in command, then your enabled native alias, then script command. If an alias has the same name as a script command, the alias wins, and the Script Manager shows that it shadows the script. /!name always bypasses aliases and scripts.
From the toolbar
Section titled “From the toolbar”A toolbar button can run a script command with the action script:<command>. The button is greyed, with the reason in its tooltip, unless an approved, running script provides that command.