bugfix: subreddit request; kgirls request
This commit is contained in:
22
bot.js
22
bot.js
@@ -86,15 +86,23 @@ function subredditRequest(subreddit)
|
||||
{
|
||||
if(req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
|
||||
var json = JSON.parse(req.responseText);
|
||||
while(true)
|
||||
{
|
||||
var i = getRandomInt(0,json.data.children.length-1);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
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")
|
||||
{
|
||||
returnText = json.data.children[i].data.url;
|
||||
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'));
|
||||
break;
|
||||
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;
|
||||
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)));
|
||||
|
Reference in New Issue
Block a user