This commit is contained in:
Daniel Odendahl Jr
2018-09-25 23:22:34 +00:00
parent a4748744c6
commit 7cdf903d3c
+3 -3
View File
@@ -12,9 +12,9 @@ module.exports = class SubredditCommand extends Command {
async run(msg, { subreddit }) {
if (!subreddit) subreddit = typeof this.subreddit === 'function' ? this.subreddit() : this.subreddit;
try {
const { post, origin } = await this.random(subreddit, msg.channel.nsfw);
if (!post) return msg.reply(`I couldn't fetch anything from r/${origin}...`);
return msg.say(this.generateText(post, origin));
const post = await this.random(subreddit, msg.channel.nsfw);
if (!post) return msg.reply(`I couldn't fetch anything from r/${post.origin}...`);
return msg.say(this.generateText(post.post, post.origin));
} catch (err) {
if (err.status === 403) return msg.say('This subreddit is private.');
if (err.status === 404) return msg.say('Could not find any results.');