Skip to content

Commit

Permalink
Additional docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chillymosh committed May 11, 2024
1 parent edafab6 commit 0fd8da7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
10 changes: 10 additions & 0 deletions twitchio/models/polls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ class Poll:
"""
Represents a Poll
| Status | Description |
| ----------- | ----------- |
| ACTIVE | The poll is running. |
| COMPLETED | The poll ended on schedule. |
| 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. |
Attributes
----------
id: str
Expand Down
8 changes: 8 additions & 0 deletions twitchio/models/predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ class Prediction:
"""
Represents a Prediction
| Status | Description |
| ----------- | ----------- |
| ACTIVE | The Prediction is running and viewers can make predictions. |
| CANCELED | The broadcaster canceled the Prediction and refunded the Channel Points to the participants. |
| LOCKED | The broadcaster locked the Prediction, which means viewers can no longer make predictions. |
| RESOLVED | The winning outcome was determined and the Channel Points were distributed to the viewers who predicted the correct outcome. |
Attributes
----------
id: str
Expand Down
29 changes: 27 additions & 2 deletions twitchio/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,9 @@ async def fetch_polls(
"""
Fetches polls that the broadcaster created.
!!! info
Polls are available for 90 days after they're created.
??? note
Requires a user access token that includes the `channel:read:polls` or `channel:manage:polls` scope.
The user ID in the access token must match the broadcaster's ID.
Expand Down Expand Up @@ -2227,7 +2230,13 @@ async def create_poll(

async def end_poll(self, *, id: str, token_for: str, status: Literal["ARCHIVED", "TERMINATED"]) -> Poll:
"""
End an active poll.
End an active poll. You have the option to end it or end it and archive it.
!!! info
Status must be set to one of the below.
- 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.
??? tip
You can also call this method directly on a Poll object with [`end_poll`][twitchio.models.polls.Poll.end_poll]
Expand Down Expand Up @@ -2257,6 +2266,9 @@ async def fetch_predictions(
"""
Fetches predictions that the broadcaster created.
!!! info
If the number of outcomes is two, the color is BLUE for the first outcome and PINK for the second outcome. If there are more than two outcomes, the color is BLUE for all outcomes.
??? note
Requires a user access token that includes the `channel:read:predictions` or `channel:manage:predictions` scope.
The user ID in the access token must match the broadcaster's ID.
Expand Down Expand Up @@ -2300,7 +2312,7 @@ async def create_prediction(
"""
Creates a prediction that viewers in the broadcaster's channel can vote on.
The prediction begins as soon as it's created. You may run only one poll at a time.
The prediction begins as soon as it's created. You may run only one prediction at a time.
??? note
Requires a user access token that includes the `channel:manage:predictions` scope.
Expand Down Expand Up @@ -2366,6 +2378,19 @@ async def end_prediction(
"""
End an active prediction.
!!! info
The status to set the prediction to. Possible case-sensitive values are:
- RESOLVED — The winning outcome is determined and the Channel Points are distributed to the viewers who predicted the correct outcome.
- CANCELED — The broadcaster is canceling the prediction and sending refunds to the participants.
- LOCKED — The broadcaster is locking the prediction, which means viewers may no longer make predictions.
The broadcaster can update an active prediction to LOCKED, RESOLVED, or CANCELED; and update a locked prediction to RESOLVED or CANCELED.
The broadcaster has up to 24 hours after the prediction window closes to resolve the prediction. If not, Twitch sets the status to CANCELED and returns the points.
A winning_outcome_id must be provided when setting to RESOLVED>
??? tip
You can also call this method directly on a Prediction object with [`end_poll`][twitchio.models.predictions.Prediction.end_prediction]
Expand Down

0 comments on commit 0fd8da7

Please sign in to comment.