bugfix: subreddit request; kgirls request
This commit is contained in:
10
bot.js
10
bot.js
@@ -86,16 +86,24 @@ function subredditRequest(subreddit)
|
|||||||
{
|
{
|
||||||
if(req.readyState == 4 && req.status == 200)
|
if(req.readyState == 4 && req.status == 200)
|
||||||
{
|
{
|
||||||
|
|
||||||
var json = JSON.parse(req.responseText);
|
var json = JSON.parse(req.responseText);
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
var i = getRandomInt(0,json.data.children.length-1);
|
var i = getRandomInt(0,json.data.children.length-1);
|
||||||
|
try
|
||||||
|
{
|
||||||
if(json.data.children[i].data.post_hint === "image" || json.data.children[i].data.post_hint === "link" || json.data.children.data.post_hint === "rich:video")
|
if(json.data.children[i].data.post_hint === "image" || json.data.children[i].data.post_hint === "link" || json.data.children.data.post_hint === "rich:video")
|
||||||
{
|
{
|
||||||
returnText = json.data.children[i].data.url;
|
returnText = json.data.children[i].data.url;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (error) // error parsing json
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +319,7 @@ client.on('message', message => {
|
|||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? redditbooruRequest('bishounen') : subredditRequest('bishounen'));
|
message.channel.send((Math.floor(Math.random() * 2) == 0) ? redditbooruRequest('bishounen') : subredditRequest('bishounen'));
|
||||||
break;
|
break;
|
||||||
case 'kgirls':
|
case 'kgirls':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? redditbooruRequest('kpics') : imgurRequest('kpics', 5));
|
message.channel.send((Math.floor(Math.random() * 2) == 0) ? redditbooruRequest('kpics') : ((Math.floor(Math.random() * 2) == 0) ? imgurRequest('kpics', 5) : subredditRequest('kpopfap')));
|
||||||
break;
|
break;
|
||||||
case 'kboys':
|
case 'kboys':
|
||||||
message.channel.send((Math.floor(Math.random() * 2) == 0) ? imgurRequest('kfanservice',1) : ((Math.floor(Math.random() * 2) == 0) ? imgurRequest('kpecs',1) : imgurRequest('cutekboys', 1)));
|
message.channel.send((Math.floor(Math.random() * 2) == 0) ? imgurRequest('kfanservice',1) : ((Math.floor(Math.random() * 2) == 0) ? imgurRequest('kpecs',1) : imgurRequest('cutekboys', 1)));
|
||||||
|
Reference in New Issue
Block a user