Discord bot to check if user is live

I have a discord bot but wanted to have it check if a specific user is live.
edit: got the response back as 200 ok. but not sure how to tell if it is live.
the documents response and this response are very different: ( the stream object come back as null. https://dev.twitch.tv/docs/v5/reference/streams/#get-stream-by-user

axios.get('https://api.twitch.tv/kraken/streams/143219629')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

I think that’s ok. You just get the response from Server.

You can also parse the result as JSON and check ‘[stream][stream-type]’ value, that can be null (not streaming), 'rerun’ (on a vodcast), otherwise streamer is live (I can’t remember the actual valie for live streaming).

Yes, if you get a {“stream”: null}, then the channel is offline, if the channel is live you get the full stream object as shown in the example on the docs.

You may want to consider Twitch Webhooks instead of long polling

https://dev.twitch.tv/docs/api/webhooks-guide/

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