added more debug
This commit is contained in:
6
bot.js
6
bot.js
@@ -184,17 +184,19 @@ function imgurRequest(subreddit, page_max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Abstracted Reddit Json media grab.
|
// Abstracted Reddit Json media grab.
|
||||||
// todo I think since it's randomly picking indices but children.length times, it's missing rare items.
|
// todo I think since it's randomly picking indices but children.length * 2 times, it's missing rare items.
|
||||||
function handleRedditJson(data) {
|
function handleRedditJson(data) {
|
||||||
let json = data.json();
|
let json = data.json();
|
||||||
if (json.data) {
|
if (json.data) {
|
||||||
for (let i = 0; i < json.data.children.length; i++) {
|
for (let i = 0; i < json.data.children.length * 2; i++) {
|
||||||
let rand = getRandomInt(0, json.data.children.length - 1);
|
let rand = getRandomInt(0, json.data.children.length - 1);
|
||||||
|
|
||||||
if (json.data.children[rand].data.post_hint === "image" || json.data.children[rand].data.post_hint === "link" || json.data.children.data.post_hint === "rich:video") {
|
if (json.data.children[rand].data.post_hint === "image" || json.data.children[rand].data.post_hint === "link" || json.data.children.data.post_hint === "rich:video") {
|
||||||
return json.data.children[rand].data.url;
|
return json.data.children[rand].data.url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sendToBotTestingChannel("json data:" + json.data);
|
||||||
}
|
}
|
||||||
// What if we don't find anything i.e. r/dogs but its valid subreddit.
|
// What if we don't find anything i.e. r/dogs but its valid subreddit.
|
||||||
return "";
|
return "";
|
||||||
|
Reference in New Issue
Block a user