Channel points and viewers
One points wallet for the channel, redeems, predictions, and the viewers who keep coming back.
Functions
points.name()
What the points are called ("points", or the streamer's own name for them).
Returns string
points.get(user)
A viewer's points (0 when they have none).
user:ChatAuthor|string
Returns integer
points.account(user)
{ name, points, earned, spent }, or nil.
user:ChatAuthor|string
Returns table?
points.add(user, n, reason)
Give points (negative takes them, never below zero): the new balance.
Name
Type
Returns integer
points.take(user, n, reason)
Take points if they have enough: true and the new balance, or false and why.
Name
Type
Returns boolean ok; integer|string balance_or_why
points.set(user, n, reason)
Set a viewer's points.
Name
Type
Returns integer
points.transfer(from, to, n)
Move points between viewers (false when the giver hasn't enough).
Name
Type
Returns boolean
points.top(n)
The richest viewers: { { id, name, points, rank } } (10 by default).
n:integer, optional
Returns table[]
points.on(event, handler)
Hear Event.PointsChange (points.on("change", fn)).
event:stringhandler:fun(e: table)
Returns integer id
points.off(id)
Stop a handler made with points.on.
id:integer
Returns boolean found
redeems.add(spec)
Something viewers buy with points: chat types "!redeem <name>" (and "!redeem" lists them). The cost
is taken first; on_redeem returning false (or failing) gives it back. Every plugin's redeems
show on the Points page. and "chat.read".
spec:{ name: string, cost: integer, cooldown: number?, per_user: number?, description: string?, on_redeem: fun(ctx: RedeemContext): boolean? }
Returns string name
redeems.remove(name)
Stop a redeem.
name:string
Returns boolean found
redeems.list()
This plugin's redeems: { { name, cost, cooldown, per_user, description, used } }.
Returns table[]
Prediction:status()
{ question, status = "open"|"locked"|"resolved"|"cancelled", total, winner, outcomes = { { label, points, people } } }.
Returns table
Prediction:lock()
Stop taking bets.
Returns boolean
Prediction:resolve(outcome)
Pick the winning outcome: its backers share the whole pot, in proportion to their bets.
outcome:integer
Returns boolean
Prediction:cancel()
Call it off and give every bet back.
Returns boolean
Prediction:bet(user, outcome, amount)
Bet for a viewer (what "!bet 1 50" does): their whole bet, or nil and why.
Name
Type
Returns integer? total; string? why
Prediction:on_change(fn)
Run a function whenever the bets or the status change.
fn:fun(status: table)
predictions.start(spec)
Viewers bet points on what happens: "!bet <outcome number> <points>". Locks by itself after
seconds. Overlays get prediction_question, prediction_status and prediction_<n>_label /
_points / _percent. (and "chat.read" for !bet).
spec:{ question: string, outcomes: string[]?, seconds: number?, min: integer?, max: integer?, dashboard: boolean? }
Returns Prediction
predictions.current()
The prediction running now (or the last one), or nil.
Returns Prediction?
viewers.get(user)
What this PC knows of a viewer across streams, or nil.
user:ChatAuthor|string
Returns Regular?
viewers.top(n, by)
The top viewers by "messages" (default), "streams", "super_chats", "last_seen" or "first_seen".
n:integer, optionalby:string, optional
Returns Regular[]
viewers.count()
How many viewers have chatted.
Returns integer
Types
Open a type to see its fields; type names above link here.

