Shower Thought Command

This commit is contained in:
Daniel Odendahl Jr
2017-10-19 22:47:37 +00:00
parent 9a65e88a30
commit ff6ffec639
3 changed files with 31 additions and 4 deletions
+3 -3
View File
@@ -28,14 +28,14 @@ module.exports = class RedditCommand extends Command {
.get(`https://www.reddit.com/r/${subreddit}/new.json`)
.query({ sort: 'new' });
if (!body.data.children.length) return msg.say('Could not find any results.');
const post = body.data.children[Math.floor(Math.random() * body.data.children.length)].data;
if (!msg.channel.nsfw && post.over_18) return msg.say('This post is only viewable in NSFW channels.');
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 embed = new MessageEmbed()
.setColor(0xFF4500)
.setAuthor('Reddit', 'https://i.imgur.com/DSBOK0P.png')
.setURL(`https://www.reddit.com${post.permalink}`)
.setTitle(post.title)
.setDescription(`[View URL Here](${post.url})`)
.addField(' Upvotes',
post.ups, true)
.addField(' Downvotes',