Change Channel Title and Game

client.api forces the method to be “GET” (Reference) which I had committed a fix for (12d7e82 & b954cac) but it got skipped from merging to master and I don’t have access on NPM to update the module, only Schmoopiie can. Use the request library directly instead:

let { channelID, authToken, clientID } = require('../config'); // Or whatever

function putItem(status, game) {
	return request({
		baseUrl: 'https://api.twitch.tv/kraken/',
		url: 'channels/' + channelID,
		method: 'PUT',
		headers: {
			Accept: 'application/vnd.twitchtv.v5+json',
			Authorization: 'OAuth ' + authToken,
			'Client-ID': clientID
		},
		json: true,
		body: {
			channel: { status, game }
		}
	}, (err, { statusCode }, body) => {
		if(err) {
			console.log(err);
		}
		else if(statusCode !== 200) {
			console.log({ statusCode, body });
		}
		else {
			console.log(body);
		}
	});
}

putItem('Hey, we\'re playing games up in here!', 'Destiny'); // Or whatever
2 Likes