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,14 +1,15 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const facts = require('../../assets/json/dog-fact');
module.exports = class DogCommand extends Command {
constructor(client) {
super(client, {
name: 'dog',
aliases: ['puppy'],
aliases: ['puppy', 'dog-fact', 'puppy-fact', 'inu', 'inu-fact'],
group: 'random-img',
memberName: 'dog',
description: 'Responds with a random dog image.',
description: 'Responds with a random dog image and fact.',
clientPermissions: ['ATTACH_FILES'],
credit: [
{
@@ -24,7 +25,7 @@ module.exports = class DogCommand extends Command {
async run(msg) {
try {
const { body } = await request.get('https://dog.ceo/api/breeds/image/random');
return msg.say({ files: [body.message] });
return msg.say(facts[Math.floor(Math.random() * facts.length)], { files: [body.message] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}