Fix Reddit

This commit is contained in:
Daniel Odendahl Jr
2017-08-30 02:25:19 +00:00
parent 9e26a1ce60
commit fac48bdda9
2 changed files with 9 additions and 11 deletions
+8 -10
View File
@@ -27,22 +27,20 @@ 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)];
if (!post.data) return msg.say('This post has no data, try again!');
if (!msg.channel.nsfw && post.data.over_18) return msg.say('This post is only viewable in NSFW channels.');
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 embed = new MessageEmbed()
.setColor(0xFF4500)
.setAuthor('Reddit', 'https://i.imgur.com/V6hXniU.png')
.setURL(`https://www.reddit.com${post.data.permalink}`)
.setTitle(post.data.title)
.setDescription(`[View URL Here](${post.data.url})`)
.setThumbnail(post.data.thumbnail !== 'self' ? post.data.thumbnail : null)
.setURL(`https://www.reddit.com${post.permalink}`)
.setTitle(post.title)
.setDescription(`[View URL Here](${post.url})`)
.addField(' Upvotes',
post.data.ups, true)
post.ups, true)
.addField(' Downvotes',
post.data.downs, true)
post.downs, true)
.addField(' Score',
post.data.score, true);
post.score, true);
return msg.embed(embed);
} catch (err) {
if (err.status === 403) return msg.say('This subreddit is private.');
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "33.0.1",
"version": "33.0.2",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {