2020-11-07 15:16:54 +00:00
|
|
|
// Required components
|
2020-11-04 17:00:23 +00:00
|
|
|
const { command } = require('vylbot-core');
|
|
|
|
const { MessageEmbed } = require('discord.js');
|
2021-05-29 10:44:00 +01:00
|
|
|
const { randomBunny } = require('random-bunny');
|
2020-11-04 17:00:23 +00:00
|
|
|
|
2020-11-07 15:16:54 +00:00
|
|
|
// Command variables
|
2020-11-04 17:00:23 +00:00
|
|
|
const embedColor = "0x3050ba";
|
|
|
|
|
2020-11-07 15:16:54 +00:00
|
|
|
// Command class
|
2020-11-04 17:00:23 +00:00
|
|
|
class bunny extends command {
|
|
|
|
constructor() {
|
2020-11-07 15:16:54 +00:00
|
|
|
// Set run method, description, and category
|
2020-11-04 17:00:23 +00:00
|
|
|
super("bunny");
|
|
|
|
super.description = "Gives you a random bunny";
|
|
|
|
super.category = "Fun";
|
|
|
|
}
|
|
|
|
|
2020-11-07 15:16:54 +00:00
|
|
|
// Run method
|
2020-11-04 17:00:23 +00:00
|
|
|
bunny(context) {
|
2020-11-07 15:16:54 +00:00
|
|
|
// Get a random post from r/Rabbits
|
2021-05-29 10:44:00 +01:00
|
|
|
randomBunny('rabbits', 'hot', (res) => {
|
2020-11-07 15:16:54 +00:00
|
|
|
// Create an embed containing the random image
|
2021-02-17 18:12:45 +00:00
|
|
|
const embed = new MessageEmbed()
|
2020-11-04 17:00:23 +00:00
|
|
|
.setColor(embedColor)
|
2021-05-29 10:44:00 +01:00
|
|
|
.setTitle(res.title)
|
|
|
|
.setImage(res.url)
|
|
|
|
.setURL("https://reddit.com" + res.permalink)
|
|
|
|
.setFooter(`r/Rabbits · ${res.ups} upvotes`);
|
2020-11-04 17:00:23 +00:00
|
|
|
|
2020-11-07 15:16:54 +00:00
|
|
|
// Send the embed
|
2020-11-04 17:00:23 +00:00
|
|
|
context.message.channel.send(embed);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 15:16:54 +00:00
|
|
|
module.exports = bunny;
|