Closed ghost closed 8 years ago
Move your callback inside the client.api function..
client.on("chat", function (channel, user, message, self) {
if (message.toLowerCase() == '!v') {
client.api({
url: "https://api.twitch.tv/kraken/streams/" + channel.replace("#", ""),
method: "GET"
}, function (err, res, body) {
console.log(body);
});
}
});
You also have a typo methon
and because you are using the channel
variable, use channel.replace("#", "")
to remove the #
.
:+1:
Thanks guys for help, now it's working. But i have one more question. How to get number of viewers and send it to the chat?
You can use the /streams/:channel endpoint of the Twitch API.
If the stream is offline, stream
will be null
in that endpoint.
Edit: Oh, it was linked Mobile Github's not amazing on a dark screen.
Which is also specified on the page I linked.
I'm trying to do command, that will get number of viewers and say that number into the chat. But when i trying to do this, i get:
The code is
How can i fix this?