Closed SloppierKitty7 closed 8 years ago
mybot.on("message", function(message) {
if (message.content === "!Live") {
getJSON("https://api.twitch.tv/kraken/streams/Jonathan_x64", function(c) {
c = JSON.parse(c);
if (c.stream == null) {
mybot.reply(message, "she is currently not live");
} else {
mybot.reply(message, "she is currently live");
}
});
}
});
You can't use the callback like that, try to follow the twitch link. Also I don't know if getJSON does this automatically for you but you need to parse it into an actual json object.
`undefined:1 undefined ^
SyntaxError: Unexpected token u in JSON at position 0
at Object.parse (native)
at E:\my ultemet bot\index.js:26:22
at Request._callback (E:\my ultemet bot\node_modules\get-JSON\lib\node.js:11:5)
at Request.self.callback (E:\my ultemet bot\node_modules\request\request.js:200:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.
`
@GexoXYZ doing that now gives this error
@Samutz its https://www.npmjs.com/package/get-json i'm only useing it becous i could not get jquery to work
You're using it wrong, your c
is the error
, use something like function(error, response)
instead.
But I'm not sure about the json now, would be response.result.stream
maybe?
@BrunoMoreira991 could you provide a snippet of what it should look like
mybot.on("message", function(message) {
if (message.content === "!Live") {
getJSON("https://api.twitch.tv/kraken/streams/Jonathan_x64", function(err, res) {
if (res.stream == null) {
mybot.reply(message, "she is currently not live");
} else {
mybot.reply(message, "she is currently live");
}
});
}
});
Thanks @GexoXYZ working now
can you close the issue ty
also wont long anything in the console when using console.log