Chat commands and tools
Chat commands with cooldowns and roles, rate limits, waiting for a viewer's answer, emotes.
Functions
commands.add(name, opts, fn)
Run a function when someone types !name in chat. Return false from it when the command didn't
count (bad arguments): its cooldown isn't used.
Name
Type
Returns string name
commands.remove(name)
Stop a command (and its aliases).
name:string
Returns boolean found
commands.list()
Every command this plugin added.
Returns CommandInfo[]
rate.limit(key, n, secs)
Count one use of key: true while it is under n uses in secs seconds, otherwise false and
the seconds to wait. rate.limit("hug:" .. chat.author.id, 3, 60).
Name
Type
Returns boolean ok; integer? wait_seconds
rate.reset(key)
Forget the uses of one key (or of every key).
key:string, optional
Waiting:cancel()
Stop waiting (the callback isn't called).
chats.wait_for(spec, callback)
Wait for the next chat line that fits: callback(chat), or callback(nil) when the time is up.
"@ann, pick a number": chats.wait_for({ from = "@ann", match = "^%d+$" }, function(c) … end).
spec:WaitSpeccallback:fun(chat: Chat?)
Returns Waiting
chats.rate(minutes)
Chat messages a minute, over the last minutes (1 by default).
minutes:number, optional
Returns number
chats.from(user, n)
One viewer's recent lines (by name or channel id), oldest first.
user:stringn:integer, optional. how many (20 by default)
Returns Chat[]
emotes.list(opts)
The custom emoji used in recent chat, most used first.
opts:EmoteQuery, optional
Returns Emote[]
emotes.top(n, opts)
The n most used custom emoji (5 by default).
n:integer, optionalopts:EmoteQuery, optional
Returns Emote[]
emotes.image(name)
An emoji's picture from recent chat (":fire:" or "fire"), or nil.
name:string
Returns string?
Types
Open a type to see its fields; type names above link here.

