Merge random animal and animal fact commands

This commit is contained in:
Dragon Fire
2021-01-14 19:31:08 -05:00
parent e43f0b73d4
commit 473ce2b9d9
8 changed files with 19 additions and 71 deletions
+4 -3
View File
@@ -1,15 +1,16 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const facts = require('../../assets/json/cat-fact');
const { THECATAPI_KEY } = process.env;
module.exports = class CatCommand extends Command {
constructor(client) {
super(client, {
name: 'cat',
aliases: ['neko', 'kitty', 'meow'],
aliases: ['neko', 'kitty', 'meow', 'cat-fact', 'neko-fact', 'kitty-fact', 'meow-fact'],
group: 'random-img',
memberName: 'cat',
description: 'Responds with a random cat image.',
description: 'Responds with a random cat image and fact.',
clientPermissions: ['ATTACH_FILES'],
credit: [
{
@@ -31,7 +32,7 @@ module.exports = class CatCommand extends Command {
mime_types: 'jpg,png'
})
.set({ 'x-api-key': THECATAPI_KEY });
return msg.say({ files: [body[0].url] });
return msg.say(facts[Math.floor(Math.random() * facts.length)], { files: [body[0].url] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}