polls - YoYoGames/GMEXT-Twitch GitHub Wiki

Polls

Functions

These are the functions of this module:



Back To Top

twitch_polls_get_polls

Twitch Endpoint: Get Polls

This function gets a list of polls that the broadcaster created.

Polls are available for 90 days after they're created.

Note

Requires a user access token that includes the TWITCH_SCOPE_CHANNEL_READ_POLLS or TWITCH_SCOPE_CHANNEL_MANAGE_POLLS scope.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_polls_get_polls(broadcaster_id, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster that created the polls. This ID must match the user ID in the user access token.
optionals Struct The optional parameters to be passed into the function:

- id : Real of Array of Real : A list of IDs that identify the polls to return. To specify more than one ID, pass an array with the IDs of each poll you want to get. You may specify a maximum of 20 IDs. Specify this parameter only if you want to filter the list that the request returns. The endpoint ignores duplicate IDs and those not owned by this broadcaster.
- first : String : The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 20 items per page. The default is 20.
- after : String : The cursor used to get the next page of results. The Pagination struct in the response contains the cursor's value. Read more
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array A list of polls. The polls are returned in descending order of start time unless you specify IDs in the request, in which case they're returned in the same order as you passed them in the request. The list is empty if the broadcaster hasn't created polls.
 ├── id String An ID that identifies the poll.
 ├── broadcaster_id String An ID that identifies the broadcaster that created the poll.
 ├── broadcaster_name String The broadcaster's display name.
 ├── broadcaster_login String The broadcaster's login name.
 ├── title String The question that viewers are voting on. For example, What game should I play next? The title may contain a maximum of 60 characters.
 ├── choices Array A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices.
         ├── id String An ID that identifies this choice.
         ├── title String The choice's title. The title may contain a maximum of 25 characters.
         ├── votes Real The total number of votes cast for this choice.
         ├── channel_points_votes Real The number of votes cast using Channel Points.
         └── bits_votes Real Not used; will be set to 0.
 ├── bits_voting_enabled Boolean Not used; will be set to false.
 ├── bits_per_vote Real Not used; will be set to 0.
 ├── channel_points_voting_enabled Boolean A Boolean value that indicates whether viewers may cast additional votes using Channel Points. For information about Channel Points, see Channel Points Guide.
 ├── channel_points_per_vote Real The number of points the viewer must spend to cast one additional vote.
 ├── status String The poll's status. Valid values are: "ACTIVE" — The poll is running. "COMPLETED" — The poll ended on schedule (see the duration field). "TERMINATED" — The poll was terminated before its scheduled end. "ARCHIVED" — The poll has been archived and is no longer visible on the channel. "MODERATED" — The poll was deleted. "INVALID" — Something went wrong while determining the state.
 ├── duration Real The length of time (in seconds) that the poll will run for.
 ├── started_at String The UTC date and time (in RFC3339 format) of when the poll began.
 ├── ended_at String The UTC date and time (in RFC3339 format) of when the poll ended. If status is "ACTIVE", this field is set to undefined.
pagination Struct Contains the information used to page through the list of results. The struct is empty if there are no more pages left to page through. Read More
 └── cursor String The cursor used to get the next page of results. Use the cursor to set the request's after parameter.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_polls_create_poll

Twitch Endpoint: Create Poll

This function creates a poll that viewers in the broadcaster's channel can vote on.

The poll begins as soon as it's created. You may run only one poll at a time.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_CHANNEL_MANAGE_POLLS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_polls_create_poll(broadcaster_id, title, choices, duration, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster that's running the poll. This ID must match the user ID in the user access token.
title String The question that viewers will vote on. For example, What game should I play next? The question may contain a maximum of 60 characters.
choices Array A list of choices that viewers may choose from. The list must contain a minimum of 2 choices and up to a maximum of 5 choices.
duration Real The length of time (in seconds) that the poll will run for. The minimum is 15 seconds and the maximum is 1800 seconds (30 minutes).
optionals Struct The optional parameters to be passed into the function:

- channel_points_voting_enabled : Boolean : A Boolean value that indicates whether viewers may cast additional votes using Channel Points. If true, the viewer may cast more than one vote but each additional vote costs the number of Channel Points specified in channel_points_per_vote. The default is false (viewers may cast only one vote). For information about Channel Points, see Channel Points Guide.
- channel_points_per_vote : Real : The number of points that the viewer must spend to cast one additional vote. The minimum is 1 and the maximum is 1000000. Set only if ChannelPointsVotingEnabled is true.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array A list that contains the single poll that you created.
 ├── id String An ID that identifies the poll.
 ├── broadcaster_id String An ID that identifies the broadcaster that created the poll.
 ├── broadcaster_name String The broadcaster's display name.
 ├── broadcaster_login String The broadcaster's login name.
 ├── title String The question that viewers are voting on. For example, What game should I play next? The title may contain a maximum of 60 characters.
 ├── choices Array A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices.
         ├── id String An ID that identifies this choice.
         ├── title String The choice's title. The title may contain a maximum of 25 characters.
         ├── votes Real The total number of votes cast for this choice.
         ├── channel_points_votes Real The number of votes cast using Channel Points.
         └── bits_votes Real Not used; will be set to 0.
 ├── bits_voting_enabled Boolean Not used; will be set to false.
 ├── bits_per_vote Real Not used; will be set to 0.
 ├── channel_points_voting_enabled Boolean A Boolean value that indicates whether viewers may cast additional votes using Channel Points. For information about Channel Points, see Channel Points Guide.
 ├── channel_points_per_vote Real The number of points the viewer must spend to cast one additional vote.
 ├── status String The poll's status. Valid values are: "ACTIVE" - The poll is running. "COMPLETED" - The poll ended on schedule (see the duration field). "TERMINATED" - The poll was terminated before its scheduled end. "ARCHIVED" - The poll has been archived and is no longer visible on the channel. "MODERATED" - The poll was deleted. "INVALID" - Something went wrong while determining the state.
 ├── duration Real The length of time (in seconds) that the poll will run for.
 ├── started_at String The UTC date and time (in RFC3339 format) of when the poll began.
 └── ended_at String The UTC date and time (in RFC3339 format) of when the poll ended. If status is "ACTIVE", this field is set to undefined.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_polls_end_poll

Twitch Endpoint: End Poll

This function ends an active poll. You have the option to end it or end it and archive it.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_CHANNEL_MANAGE_POLLS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_polls_end_poll(broadcaster_id, id, status, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster that's running the poll. This ID must match the user ID in the user access token.
id String The ID of the poll to update.
status String The status to set the poll to. Possible case-sensitive values are: "TERMINATED" - Ends the poll before the poll is scheduled to end. The poll remains publicly visible. "ARCHIVED" - Ends the poll before the poll is scheduled to end, and then archives it so it's no longer publicly visible.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array An array that contains the poll that you ended.
 ├── id String An ID that identifies the poll.
 ├── broadcaster_id String An ID that identifies the broadcaster that created the poll.
 ├── broadcaster_name String The broadcaster's display name.
 ├── broadcaster_login String The broadcaster's login name.
 ├── title String The question that viewers are voting on. For example, What game should I play next? The title may contain a maximum of 60 characters.
 ├── choices Array A list of choices that viewers can choose from. The list will contain a minimum of two choices and up to a maximum of five choices.
         ├── id String An ID that identifies this choice.
         ├── title String The choice's title. The title may contain a maximum of 25 characters.
         ├── votes Real The total number of votes cast for this choice.
         ├── channel_points_votes Real The number of votes cast using Channel Points.
         └── bits_votes Real Not used; will be set to 0.
 ├── bits_voting_enabled Boolean Not used; will be set to false.
 ├── bits_per_vote Real Not used; will be set to 0.
 ├── channel_points_voting_enabled Boolean A Boolean value that indicates whether viewers may cast additional votes using Channel Points. For information about Channel Points, see Channel Points Guide.
 ├── channel_points_per_vote Real The number of points the viewer must spend to cast one additional vote.
 ├── status String The poll's status. Valid values are: "ACTIVE" - The poll is running. "COMPLETED" - The poll ended on schedule (see the duration field). "TERMINATED" - The poll was terminated before its scheduled end. "ARCHIVED" - The poll has been archived and is no longer visible on the channel. "MODERATED" - The poll was deleted. "INVALID" - Something went wrong while determining the state.
 ├── duration Real The length of time (in seconds) that the poll will run for.
 ├── started_at String The UTC date and time (in RFC3339 format) of when the poll began.
 └── ended_at String The UTC date and time (in RFC3339 format) of when the poll ended. If status is "ACTIVE", this field is set to undefined.

Failure Callback

This method is triggered on failure.



⚠️ **GitHub.com Fallback** ⚠️