vylbot-app/commands/bunny.js

37 lines
1 KiB
JavaScript
Raw Normal View History

// 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
// Command variables
2020-11-04 17:00:23 +00:00
const embedColor = "0x3050ba";
// Command class
2020-11-04 17:00:23 +00:00
class bunny extends command {
constructor() {
// 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";
}
// Run method
2020-11-04 17:00:23 +00:00
bunny(context) {
// Get a random post from r/Rabbits
2021-05-29 10:44:00 +01:00
randomBunny('rabbits', 'hot', (res) => {
// 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
// Send the embed
2020-11-04 17:00:23 +00:00
context.message.channel.send(embed);
});
}
}
module.exports = bunny;