From 874be91270b030e1d223057b406f2102e9e8da83 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Sep 2018 00:51:44 +0200 Subject: [PATCH] reverted back to before --- commands/fun/reddit.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/commands/fun/reddit.js b/commands/fun/reddit.js index e7c0ba0..1d09466 100644 --- a/commands/fun/reddit.js +++ b/commands/fun/reddit.js @@ -19,17 +19,13 @@ module.exports = class redditCommand extends Command { } async run(message, { sub }) { - const body = await snekfetch.get('https://www.reddit.com/r/' + sub + '.json?limit=100') + const { body } = await snekfetch.get('https://www.reddit.com/r/' + sub + '.json?limit=100'); let /* the bodies hit the floor */ i = Math.floor((Math.random() * 10) + 1); - let a = 0 if (!body.data.children[1]) { return message.say('Not a valid subreddit') - } else if (!body.data.children[i].data) { - return console.log('please try again') } - while (body.data.children[i].data.post_hint !== 'image' && a == 5) { + while (body.data.children[i].data.post_hint !== 'image') { i = Math.floor((Math.random() * 100) + 1); - a++ } if (body.data.children[i].data.over_18 == true) { return message.say("No nsfw ( if you want a nsfw version of this commands use the feedback commands \"haha feedback \")")