[Node Js] Get the last follow, sub and cheers

(I’m sorry for my bad english, I’m french…)
Hi !
I’m trying to make my own bot with Node Js. I’m already using tmi.js but it doesn’t react to follow, sub and cheer…

How can I do ? Or which npm module shoud I use ?

Or maybe how can I get the follower list ?

Thank you.

Followers are not sent through the IRC so therefore tmi.js cannot react to it. It does react to subscription and cheers using these events:

  • Subscription - Username has subscribed to a channel.

    client.on("resub", function (channel, username, months, message, userstate, methods) {
        // Do your stuff.
    });
    
  • Resub - Username has resubbed on a channel.

    client.on("subscription", function (channel, username, method, message, userstate) {
        // Do your stuff.
    });
    

For followers you will need to use the Twitch API yourself. Either Kraken v5 or the new Helix.

Thx for solving 2/3 of my problem !

I would like to use kraken v5 but it does work, it always write “{“error”:“Bad Request”,“status”:400,“message”:“No client id specified”}”

That’s because with all (well, almost all) API requests you need to include your applications client id. The Twitch Docs explain how to obtain a client-id

1 Like

Ok, I got my _id and my Client ID but could you say me what’s the url to find the last follow please?
I already tried https://api.twitch.tv/kraken/channels/MY_ID/follows
and
https://api.twitch.tv/kraken/channels/MY_CLIENT_ID/follows

Use the query string:

https://api.twitch.tv/kraken/channels/MY_ID/follows?api_version=5&client_id=MY_CLIENT_ID&limit=1

or headers:

Accept: application/vnd.twitchtv.v5+json
Client-ID: MY_CLIENT_ID

https://api.twitch.tv/kraken/channels/MY_ID/follows?limit=1

See this page: Twitch API | Twitch Developers.

1 Like

Thank you for your help !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.