Appearance
Class: TwitchPrediction
Represents a Twitch prediction launched from an app: creation, lock and resolution tracking, with create / lock / end events.
Remarks
You do not instantiate this class directly: it is created and returned by k.twitch when you launch a prediction.
Example
ts
const prediction = await k.twitch.createPrediction({ ... }); // returns a TwitchPrediction
// Later, lock then resolve on the right outcome
await prediction.lock();
await prediction.resolve('winning-outcome-id');Properties
data
ts
data: TwitchPredictionData = null;Current prediction data on the Twitch side, or null until it has been created.
STATUS_CANCELED
ts
static STATUS_CANCELED: string = 'CANCELED';Status: prediction canceled (bets refunded).
STATUS_LOCKED
ts
static STATUS_LOCKED: string = 'LOCKED';Status: prediction locked (bets closed).
STATUS_RESOLVED
ts
static STATUS_RESOLVED: string = 'RESOLVED';Status: prediction resolved (a winning outcome has been chosen).
Methods
cancel()
ts
cancel(): Promise<void>;Cancels the prediction (status CANCELED): the bets are refunded.
Returns
Promise<void>
A promise resolved once the prediction has been canceled.
See
resolve to designate a winner instead.
lock()
ts
lock(): Promise<void>;Locks the prediction: closes the bets (status LOCKED).
Returns
Promise<void>
A promise resolved once the prediction has been locked.
See
resolve to then designate the winner.
resolve()
ts
resolve(outcome_id): Promise<void>;Resolves the prediction by designating the winning outcome (status RESOLVED).
Parameters
outcome_id
string
Identifier of the winning outcome.
Returns
Promise<void>
A promise resolved once the prediction has been resolved.
See
cancel to cancel and refund instead.