From dffd207c0bdc7fb355dbbf10529bebfeb6e90381 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 27 Sep 2018 20:27:34 +0200 Subject: [PATCH] higher limit for random image --- commands/fun/reddit.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/fun/reddit.js b/commands/fun/reddit.js index 0b2197b..7f9d94b 100644 --- a/commands/fun/reddit.js +++ b/commands/fun/reddit.js @@ -23,8 +23,11 @@ module.exports = class redditCommand extends Command { const { body } = await snekfetch.get('https://www.reddit.com/r/' + sub + '.json'); let /* the bodies hit the floor */ i = Math.floor((Math.random() * 10) + 1); console.log(body.data.children[i].data.post_hint) + if (body.data.dist == '0') { + return message.say('Not a valid subreddit') + } while (body.data.children[i].data.post_hint !== 'image') { - i = Math.floor((Math.random() * 10) + 1); + i = Math.floor((Math.random() * 20) + 1); } if (body.data.children[i].data.over_18 == true) { return message.say("No nsfw")