Appearance
Class: TwitchPoll
Represents a Twitch poll launched from an app: creation, state tracking and closing, with create / end events.
Remarks
You do not instantiate this class directly: it is created and returned by k.twitch when you launch a poll.
Example
ts
const poll = await k.twitch.createPoll({ ... }); // returns a TwitchPoll
poll.events.on(poll.EVENTS.END, async () => {
const data = await poll.getData();
console.log('Poll ended', data.status);
});Properties
data
ts
data: TwitchPollData = null;Current poll data on the Twitch side, or null until it has been created.
FINISH_STATUS
ts
static FINISH_STATUS: string[];List of statuses considered "finished" (poll closed).
STATUS_ARCHIVED
ts
static STATUS_ARCHIVED: string = 'ARCHIVED';Status: poll archived.
STATUS_COMPLETED
ts
static STATUS_COMPLETED: string = 'COMPLETED';Status: poll that reached its end normally.
STATUS_INVALID
ts
static STATUS_INVALID: string = 'INVALID';Status: poll invalid.
STATUS_MODERATED
ts
static STATUS_MODERATED: string = 'MODERATED';Status: poll moderated (removed by Twitch).
STATUS_TERMINATED
ts
static STATUS_TERMINATED: string = 'TERMINATED';Status: poll stopped manually before the end.
Methods
archive()
ts
archive(): Promise<void>;Archives the poll (status ARCHIVED).
Returns
Promise<void>
A promise resolved once the poll has been archived.
Remarks
Does nothing if the poll is already finished.
See
terminate to stop it instead.
getData()
ts
getData(): Promise<TwitchPollData>;Retrieves the up-to-date poll data (refreshes from Twitch if the poll is still running).
Returns
Promise<TwitchPollData>
The current TwitchPollData of the poll.
terminate()
ts
terminate(): Promise<void>;Stops the poll before the end (status TERMINATED).
Returns
Promise<void>
A promise resolved once the poll has been stopped.
Remarks
Does nothing if the poll is already finished.
See
archive to archive the poll instead.