Reputation:
I have a little chat bot for twitch and I want to make now a function where you can change the stream title. My function looks at the moment so:
public changeTitle = (new_title: string, callback: any): void => {
let t = this;
let request = require('request');
request.get("https://api.twitch.tv/kraken/channels/" + this.settings.current_channel + "?client_id="+this.settings.clientId, { json: true }, function (err, res) {
if (!err && res.statusCode === 200) {
let current_title = res.body.status;
console.log(current_title);
let request2 = require('request');
let options = {
url: "https://api.twitch.tv/kraken/channels/"+t.settings.current_channel+"?channel[status]="+current_title+new_title,
headers: {
"Authorization": "OAuth "+t.settings.clientId,
"Accept": "application/vnd.twitchtv.v2+json"
}
};
request2.put(options, (error: Error, response: any, body: any): void => {
console.log("Title changed?");
});
}
});
};
in the console.log(current_title)
I can see the current stream title.
After the console.log("Title changed?")
nothing happened.
I get the error 410 GONE. So my way to change the title is no longer supported.
Can someone show me how to change the title?
Upvotes: 0
Views: 1640
Reputation: 685
Specifically, rather than channel[status]
use just status
as a query param.
let options = {
url: "https://api.twitch.tv/kraken/channels/"+t.settings.current_channel+"?status="+new_title,
headers: {
"Authorization": "OAuth "+t.settings.clientId,
"Accept": "application/vnd.twitchtv.v2+json"
}
You'll also need the channel_editor
scope in order to use this on a given channel.
Upvotes: -1