I am Currently working on a Discord Bot for my Twitch Channel. This is the first use of C# I have had so I am learning on the way.(I have had prior experience in C and C++.)
The Bot currently will run into the Discord server and when I type a command it will return what I have set it to return.
The next thing that I am wanting to implement is a Twitch Alert in the Announcement Channel that will alert the channel when my channel goes live. I am just getting any where on how to implement the Twitch API so that I can check for the event of me going online.
My question is: How do I connect to the Twitch channel so that I can look for an event indicating the channel has gone Live?
Did you read the twitch api documentation or even search for this yourself? I have no idea about twitch or what they provide for api integrations and i figured this out with 5 minutes of googling.
Twitch has no plan to support webhooks, as mentioned here. Which means you'll have to poll for it (check the streams api to see if a channel is live or not, maybe every minute or so depending on how accurate you want it to be).
Their developer api will talk about how to determine if a channel is live or not - specifically the streams api that lives here.
To summarise what it says there, what you should send a query to the url like the following:
Replacing CHANNEL_ID
with the id of the channel you're interested in, and including your developer client id in the headers of the request. (more on this in the docs page i linked)
It will return null
if the channel is offline, or a stream
object if they are streaming.
When you make this request, you will need to check if the new value is different than the last value that you received when you queried before - if so, the channel state (live/offline) has changed and you should post a message to your discord channel.
I'm not going to code it for you, but you should be able to figure this out now. Search up on how to send a HTTP request, and how to add a custom http header (for the twitch client id header), how to parse JSON etc.