mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 13:56:25 +02:00
Fix Reddit
This commit is contained in:
@@ -27,22 +27,20 @@ module.exports = class RedditCommand extends Command {
|
|||||||
.get(`https://www.reddit.com/r/${subreddit}/new.json`)
|
.get(`https://www.reddit.com/r/${subreddit}/new.json`)
|
||||||
.query({ sort: 'new' });
|
.query({ sort: 'new' });
|
||||||
if (!body.data.children.length) return msg.say('Could not find any results.');
|
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)];
|
const post = body.data.children[Math.floor(Math.random() * body.data.children.length)].data;
|
||||||
if (!post.data) return msg.say('This post has no data, try again!');
|
if (!msg.channel.nsfw && post.over_18) return msg.say('This post is only viewable in NSFW channels.');
|
||||||
if (!msg.channel.nsfw && post.data.over_18) return msg.say('This post is only viewable in NSFW channels.');
|
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xFF4500)
|
.setColor(0xFF4500)
|
||||||
.setAuthor('Reddit', 'https://i.imgur.com/V6hXniU.png')
|
.setAuthor('Reddit', 'https://i.imgur.com/V6hXniU.png')
|
||||||
.setURL(`https://www.reddit.com${post.data.permalink}`)
|
.setURL(`https://www.reddit.com${post.permalink}`)
|
||||||
.setTitle(post.data.title)
|
.setTitle(post.title)
|
||||||
.setDescription(`[View URL Here](${post.data.url})`)
|
.setDescription(`[View URL Here](${post.url})`)
|
||||||
.setThumbnail(post.data.thumbnail !== 'self' ? post.data.thumbnail : null)
|
|
||||||
.addField('❯ Upvotes',
|
.addField('❯ Upvotes',
|
||||||
post.data.ups, true)
|
post.ups, true)
|
||||||
.addField('❯ Downvotes',
|
.addField('❯ Downvotes',
|
||||||
post.data.downs, true)
|
post.downs, true)
|
||||||
.addField('❯ Score',
|
.addField('❯ Score',
|
||||||
post.data.score, true);
|
post.score, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 403) return msg.say('This subreddit is private.');
|
if (err.status === 403) return msg.say('This subreddit is private.');
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "33.0.1",
|
"version": "33.0.2",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user