tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 215 forks source link

Userstate.subscriber is false for founders #364

Closed imaspeer closed 4 years ago

imaspeer commented 4 years ago

Actual behaviour: The subscriber value in the userstate object is false for users who have the founder badge.

Expected behaviour: The subscriber value should always be true for users who have the founder badge, as it means they have an active subscription to the channel (in addition to being among the 10/25 first subs).

Server configuration

AlcaDesign commented 4 years ago

Unfortunately, that tag comes directly from Twitch and is marked deprecated in their documentation. It should be ignored. Instead, use the badges tag to look for subscriber or founder.

client.on('message', (channel, tags, message, self) => {
    if(self) return;
    let isSub = false;
    if(tags.badges) {
        isSub = 'subscriber' in tags.badges || 'founder' in tags.badges;
    }
    console.log(`${tags.username} is ${isSub ? '' : 'not'} a subscriber.`);
});
rodrigograca31 commented 3 years ago

I'm also having this issue. thanks for the example code @AlcaDesign

I wonder if we still should additionally check for userstate.subscriber or is the code above enough?

Will a normal subscriber (non founder) have "subscriber" in the badges object? 🤔

AlcaDesign commented 3 years ago

Subscriber and founder are mutually exclusive badges. They mean the same thing (as far as being subscribed matters) but will not be included in the badges at the same time.

rodrigograca31 commented 3 years ago

👍🏻 and I guess my question was stupid because I just realized of course a subscriber will have subscriber in their badges! duh!

Then I'm not sure why we still have .subscriber in the userstate object..... 🤔

AlcaDesign commented 3 years ago

It's still there because Twitch sends the data. tmi.js isn't excluding that data but it is marked deprecated in the official Twitch documentation.