forked from Supositware/Haha-Yes
Post no longer hardcoded
This commit is contained in:
parent
b1d278ba2d
commit
00bdddaf24
1 changed files with 3 additions and 2 deletions
|
@ -23,11 +23,12 @@ module.exports = class redditCommand extends Command {
|
||||||
let a = 0
|
let a = 0
|
||||||
fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => {
|
fetch('https://www.reddit.com/r/' + sub + '.json?limit=100').then((response) => {
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (!response.data)
|
if (!response.data)
|
||||||
return message.say('Not a valid subreddit')
|
return message.say('Not a valid subreddit')
|
||||||
while (response.data.children[i].data.post_hint !== 'image') {
|
while (response.data.children[i].data.post_hint !== 'image') {
|
||||||
i = Math.floor((Math.random() * 100) + 1);
|
i = Math.floor((Math.random() * response.data.children.length));
|
||||||
|
|
||||||
a++
|
a++
|
||||||
if (a == 5)
|
if (a == 5)
|
||||||
return message.say("Could not find any images")
|
return message.say("Could not find any images")
|
||||||
|
|
Loading…
Reference in a new issue