Skip to content

Conversation

@jrutschke
Copy link
Contributor

@jrutschke jrutschke commented Jan 22, 2026

Description

For Twitch Combos Feature (currently in Beta: https://help.twitch.tv/s/article/combos?language=en_US) the message can be None.
ChannelBitsUse Event (event_bits_use) throws an error once Combos are redeemed.

Error before fix

twitchio/models/eventsub_.py", line 898, in __init__
    self.text: str | None = payload.get("message").get("text")
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

Example payload Combo: message is None

{'broadcaster_user_id': '63532168', 
'broadcaster_user_login': 'elspeth',
'broadcaster_user_name': 'Elspeth', 
'user_id': '70182062', 
'user_login': 'jacky_r', 
'user_name': 'Jacky_R', 
'bits': 5, 'type': 'combo', 
'power_up': None, 
'message': None
}

Example payload Cheer: message not None

{
'broadcaster_user_id': '63532168', 
'broadcaster_user_login': 'elspeth', 
'broadcaster_user_name': 'Elspeth', 
'user_id': '70182062', 
'user_login': 'jacky_r', 
'user_name': 'Jacky_R', 
'bits': 1, 
'type': 'cheer', 
'power_up': None, 
'message': {'text': 'Cheer1', 'fragments': [{'type': 'cheermote', 'text': 'Cheer1', 'cheermote': {'prefix': 'cheer', 'bits': 1, 'tier': 1}, 'emote': None}]}
}

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
    • I have updated the changelog with a quick recap of my changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)
  • I have read and agree to the Developer Certificate of Origin for this contribution

self.text: str | None = payload.get("message").get("text")
self.type: Literal["cheer", "power_up", "combo"] = payload["type"]
message = payload.get("message") or {}
self.text: str = message.get("text", "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case this should return None and not an empty string.
self.text: str = message.get("text") is sufficient.

This would be a breaking change otherwise for existing users checking explicitly for None and we do not need to accommodate a previous V1 instance.

Copy link
Collaborator

@chillymosh chillymosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst correcting this, you can also update the docstring for fragments by removing
Is `None` if no chat message was used.

This was probably a copy paste error on my part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants