tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 215 forks source link

How can i add !game and !title commands (TMİ.js) #308

Closed yagizdo closed 5 years ago

yagizdo commented 5 years ago

Hi. I opened a topic at https://discuss.dev.twitch.tv. They suggested that I write here. I want to add! game and! title commands. I reviewed the Twitch documents, but I still didn't understand. How do I add these commands with tmi.js by following Twitch documents? Can you help with this?

Twitch Discuss ScreenShot : image

Actual behaviour:

Expected behaviour:

Error log:

Insert your error log here

Server configuration

AlcaDesign commented 5 years ago

You can accomplish this by using the docs for Twitch like I linked in the other issue (which you should have commented on rather than opening a new issue) (and I already gave you a solution and information for creating game aliases) here and combining with the bot script I wrote here.

I will not supply support for your project(s) here as it is clearly better suited on the Twitch Dev forums. This is not an issue with tmi.js.

yagizdo commented 5 years ago

Hi again. I've reviewed your sources. But sadly I can't make Curl request. My code fails or doesn't work directly. All I want is to be able to add title and! Game commands. I've tried all the codes I've found. Please help..

AlcaDesign commented 5 years ago

You don't have to make request using cURL, those are just very basic examples using command-line functions. Again, this is definitely for the Twitch forums -- nothing to do with tmi.js.

Here is an untested example of a request to update the status and game using the request package:

const request = require('request');

const clientID = '';
const channelID = '';
const oauthToken = '';

request({
    url: 'https://api.twitch.tv/kraken/channels/' + channelID,
    json: true,
    method: 'put',
    headers: {
        'Client-ID': clientID,
        Accept: 'application/vnd.twitchtv.v5+json',
        Authorization: 'OAuth ' + oauthToken
    },
    body: {
        channel: {
            status: 'My new status',
            game: 'Counter-Strike: Global Offensive'
        }
    }
}, (err, req, body) => {
    if(err) {
        console.error(err);
    }
    else {
        console.log(body);
    }
});
yagizdo commented 5 years ago

Thank you so much. And I'm sorry for asking so many questions.