I'm writing a Twitch bot. I'd like to be able to store ranking of number of comments posted. So I'd like to label users by their Twitch ID in DB.
I wrote this get function :
5 def getId(chatter : Union[twitchio.Chatter, twitchio.PartialChatter]):
6 if isinstance(chatter,twitchio.chatter.Chatter):
7
8 userVar = chatter.channel.user()
9 print("NormalChatter", type(userVar))
10
11 return userVar
12 #return chatter.channel.user().id
13 #return chatter.id
14
15 elif isinstance(chatter, twitchio.PartialChatter):
16 return chatter.user().id
17 else:
18 print("NoneBoy")
While getting chatters from Channel object I end up with Chatter object as tested by print in line 9. Chatter object should have "id" attribute as per [https://twitchio.dev/en/stable/reference.html#twitchio.Chatter] It has the attribute, but he attribute is NULL.
I tried to get ID by using channel and "user()" coroutine, but it seems like it does not return anything other than itself (chatter.channel.user().id causes 'AttributeError: 'coroutine' object has no attribute 'id' ') I did it because I thought maybe it's some inheritance from PartialChatter obj.
Does anyone knows how to get this user ID ?
The userID is not something every developer can access and Twitch gives it sparsely. The best way to serialize users is by user name.
This is the answer I got from discord server for Twitch APIs in TwitchIO thread.