-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeme.js
35 lines (27 loc) · 902 Bytes
/
meme.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const Discord = require('discord.js');
const got = require('got');
module.exports.run = async (bot, message, args) => {
const embed = new Discord.MessageEmbed();
got('https://www.reddit.com/r/memes/random/.json')
.then(response => {
const [list] = JSON.parse(response.body);
const [post] = list.data.children;
const permalink = post.data.permalink;
const memeUrl = `https://reddit.com${permalink}`;
const memeImage = post.data.url;
const memeTitle = post.data.title;
const memeUpvotes = post.data.ups;
const memeNumComments = post.data.num_comments;
embed.setTitle(`${memeTitle}`);
embed.setURL(`${memeUrl}`);
embed.setColor('RANDOM');
embed.setImage(memeImage);
embed.setFooter(`👍 ${memeUpvotes} 💬 ${memeNumComments}`);
message.channel.send(embed);
})
.catch(console.error);
};
module.exports.config = {
name: 'meme',
aliases: [],
};