tybug / ossapi

The definitive python wrapper for the osu! api.
https://tybug.github.io/ossapi/
GNU Affero General Public License v3.0
80 stars 17 forks source link

'UserSupportAgainEvent' Attribute Error when using limit greater than default #41

Closed sortedcord closed 2 years ago

sortedcord commented 2 years ago

Saw this happen with api.user_recent_activity.

for recent_activity in api.user_recent_activity(user_id=12345, limit=4):
    print(recent_activity.scoreRank)

This works well but whenever I change the limit to be greater than 5, it always gives this error

AttributeError: 'UserSupportAgainEvent' object has no attribute 'scoreRank'

If I check the type of recent_activity whenever the limit is greater than 4, it returns RankEvent or RankLostEvent, so what is the UserSupportAgainEvent?

tybug commented 2 years ago

Because the 5th event of that user is a UserSupportAgainEvent, which means they bought supporter ("again", ie it wasn't their first time buying supporter). The scoreRank attribute obviously won't exist on this event; the only attribute that does is .user. You'll need to check what type of event recent_activity is before accessing any attributes.

sortedcord commented 2 years ago

Oh, thanks for that. Also, I shouldn't be piggybacking this issue, but whenever there is an achievement event in the recent activities it returns a ValueError: None is not a valid GameMode instead of an AchiementEvent Object. Maybe something to do with the default value set here?

tybug commented 2 years ago

you linked code for ossapi and not ossapiv2, so unless you're using api v1 I don't think that's related ;)

the actual issue was that mode could be null for EventAchivement. closed by ccd0d6898802c23d4f4c9be7fc30165e5c9d9d25, will be fixed in next release

sortedcord commented 2 years ago

Thanks again