Skip to content

Commit 25cd689

Browse files
committed
Fixed issue with Predictor model
Fixed issue with Predictor model Added repr for Predictor and PredictionOutcome
1 parent 114950a commit 25cd689

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ Master
2424
- :func:`~twitchio.Client.update_chatter_color`
2525
- Add ``duration`` and ``vod_offset`` attributes to :class:`~twitchio.Clip`
2626
- Added repr for :class:`~twitchio.CustomReward`
27+
- Added repr for :class:`~twitchio.PredictionOutcome`
2728
- Add extra attributes to :class:`~twitchio.UserBan`
2829
- Bug fixes
2930
- Added ``self.registered_callbacks = {}`` to :func:`~twitchio.Client.from_client_credentials`
3031
- Allow empty or missing initial_channels to trigger :func:`~twitchio.Client.event_ready`
3132
- Corrected :func:`twitchio.CustomRewardRedemption.fulfill` endpoint typo and creation
3233
- Corrected :func:`twitchio.CustomRewardRedemption.refund` endpoint typo and creation
3334
- Changed :func:`~twitchio.Client.join_channels` logic to handle bigger channel lists better
35+
- Corrected :class:`~twitchio.Predictor` slots and user keys, repr has also been added
3436

3537
- ext.commands
3638
- Bug fixes

twitchio/models.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,13 +1090,15 @@ class Predictor:
10901090
Number of Channel Points won by the user.
10911091
"""
10921092

1093-
__slots__ = ("outcome_id", "title", "channel_points", "color")
1093+
__slots__ = ("channel_points_used", "channel_points_won", "user")
10941094

10951095
def __init__(self, http: "TwitchHTTP", data: dict):
10961096
self.channel_points_used: int = data["channel_points_used"]
10971097
self.channel_points_won: int = data["channel_points_won"]
1098-
self.user = PartialUser(http, data["user"]["id"], data["user"]["name"])
1098+
self.user = PartialUser(http, data["user_id"], data["user_login"])
10991099

1100+
def __repr__(self):
1101+
return f"<Predictor user={self.user} channel_points_used={self.channel_points_used} channel_points_won={self.channel_points_won}>"
11001102

11011103
class PredictionOutcome:
11021104
"""
@@ -1129,7 +1131,11 @@ def __init__(self, http: "TwitchHTTP", data: dict):
11291131
if data["top_predictors"]:
11301132
self.top_predictors: List[Predictor] = [Predictor(http, x) for x in data["top_predictors"]]
11311133
else:
1134+
11321135
self.top_predictors: List[Predictor] = None
1136+
def __repr__(self):
1137+
return f"<PredictionOutcome outcome_id={self.outcome_id} title={self.title} channel_points={self.channel_points} color={self.color} users={self.users}>"
1138+
11331139

11341140
@property
11351141
def colour(self) -> str:

0 commit comments

Comments
 (0)