From 81472278185d79c6837263d9136e7761fcc06650 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 6 Sep 2018 14:29:13 +0000 Subject: [PATCH] Update this too --- commands/random/reddit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/random/reddit.js b/commands/random/reddit.js index ce5c349e..d37537bc 100644 --- a/commands/random/reddit.js +++ b/commands/random/reddit.js @@ -29,9 +29,9 @@ module.exports = class RedditCommand extends Command { sort: 'new', limit: 100 }); - const allowed = msg.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18); - if (!allowed.length) return msg.say('Could not find any results.'); - const post = allowed[Math.floor(Math.random() * allowed.length)].data; + const posts = body.data.children.filter(post => post.data && (msg.channel.nsfw ? true : !post.data.over_18)); + if (!posts.length) return msg.say('Could not find any results.'); + const post = posts[Math.floor(Math.random() * posts.length)].data; return msg.say(stripIndents` **${post.title}**