I’m working on a Twitch bot and trying to add a feature that lets users update the stream title. My current code isn’t working and I keep getting a 410 GONE error.
Here’s what I have so far:
public updateStreamTitle = (title: string, done: any): void => {
const self = this;
const http = require('request');
http.get("https://api.twitch.tv/kraken/channels/" + this.config.channel_name + "?client_id="+this.config.appId, { json: true }, function (error, response) {
if (!error && response.statusCode === 200) {
const existing_title = response.body.status;
console.log(existing_title);
const http2 = require('request');
const params = {
url: "https://api.twitch.tv/kraken/channels/"+self.config.channel_name+"?channel[status]="+existing_title+title,
headers: {
"Authorization": "OAuth "+self.config.appId,
"Accept": "application/vnd.twitchtv.v2+json"
}
};
http2.put(params, (err: Error, resp: any, data: any): void => {
console.log("Stream title updated?");
});
}
});
};
The current title shows up correctly in the console, but after that nothing happens. I think the API endpoint I’m using is deprecated. What’s the correct way to modify stream titles now?