From 473ce2b9d9a512128e99a67de8048936072ccf99 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Thu, 14 Jan 2021 19:31:08 -0500 Subject: [PATCH] Merge random animal and animal fact commands --- README.md | 11 ++++------- commands/random-img/bunny.js | 9 ++++++--- commands/random-img/cat.js | 7 ++++--- commands/random-img/dog.js | 7 ++++--- commands/random-res/bunny-fact.js | 18 ------------------ commands/random-res/cat-fact.js | 18 ------------------ commands/random-res/dog-fact.js | 18 ------------------ package.json | 2 +- 8 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 commands/random-res/bunny-fact.js delete mode 100644 commands/random-res/cat-fact.js delete mode 100644 commands/random-res/dog-fact.js diff --git a/README.md b/README.md index 0d6412c0..7194b862 100644 --- a/README.md +++ b/README.md @@ -260,7 +260,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 576 +Total: 573 ### Utility: @@ -320,14 +320,11 @@ Total: 576 * **advice:** Responds with a random bit of advice. * **axis-cult:** Responds with a teaching of the Axis Cult. * **boredom:** Responds with a random activity to try when you're bored. -* **bunny-fact:** Responds with a random bunny fact. -* **cat-fact:** Responds with a random cat fact. * **charlie-charlie:** Asks your question to Charlie. * **choose:** Chooses between options you provide. * **chuck-norris:** Responds with a random Chuck Norris joke. * **coin:** Flips a coin. * **compliment:** Compliments a user. -* **dog-fact:** Responds with a random dog fact. * **draw-cards:** Draws a random hand of playing cards. * **fact-core:** Responds with a random Fact Core quote. * **fact:** Responds with a random fact. @@ -377,9 +374,9 @@ Total: 576 * **ai-waifu:** Responds with a randomly generated waifu. * **awwnime:** Responds with cute random anime art. * **bird:** Responds with a random image of a bird. -* **bunny:** Responds with a random image of a bunny. -* **cat:** Responds with a random cat image. -* **dog:** Responds with a random dog image. +* **bunny:** Responds with a random bunny image and fact.. +* **cat:** Responds with a random cat image and fact. +* **dog:** Responds with a random dog image and fact. * **duck:** Responds with a random duck image. * **fidget:** Responds with a random image of Fidget. * **food:** Responds with a randomly generated food. diff --git a/commands/random-img/bunny.js b/commands/random-img/bunny.js index c21dcde8..8ff22885 100644 --- a/commands/random-img/bunny.js +++ b/commands/random-img/bunny.js @@ -1,14 +1,15 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); +const facts = require('../../assets/json/bunny-fact'); module.exports = class BunnyCommand extends Command { constructor(client) { super(client, { name: 'bunny', - aliases: ['bun', 'rabbit'], + aliases: ['bun', 'rabbit', 'bunny-fact', 'bun-fact', 'rabbit-fact'], group: 'random-img', memberName: 'bunny', - description: 'Responds with a random image of a bunny.', + description: 'Responds with a random bunny image and fact.', clientPermissions: ['ATTACH_FILES'], credit: [ { @@ -35,7 +36,9 @@ module.exports = class BunnyCommand extends Command { } else { fileToSend = gif.body; } - return msg.say({ files: [{ attachment: fileToSend, name: `${body.id}.${fileType}` }] }); + return msg.say(facts[Math.floor(Math.random() * facts.length)], { + files: [{ attachment: fileToSend, name: `${body.id}.${fileType}` }] + }); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } diff --git a/commands/random-img/cat.js b/commands/random-img/cat.js index fa53d3e5..b35b96aa 100644 --- a/commands/random-img/cat.js +++ b/commands/random-img/cat.js @@ -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!`); } diff --git a/commands/random-img/dog.js b/commands/random-img/dog.js index a80b2c4c..e87ae9e3 100644 --- a/commands/random-img/dog.js +++ b/commands/random-img/dog.js @@ -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!`); } diff --git a/commands/random-res/bunny-fact.js b/commands/random-res/bunny-fact.js deleted file mode 100644 index c05c79f2..00000000 --- a/commands/random-res/bunny-fact.js +++ /dev/null @@ -1,18 +0,0 @@ -const Command = require('../../structures/Command'); -const facts = require('../../assets/json/bunny-fact'); - -module.exports = class BunnyFactCommand extends Command { - constructor(client) { - super(client, { - name: 'bunny-fact', - aliases: ['bun-fact', 'rabbit-fact'], - group: 'random-res', - memberName: 'bunny-fact', - description: 'Responds with a random bunny fact.' - }); - } - - run(msg) { - return msg.say(facts[Math.floor(Math.random() * facts.length)]); - } -}; diff --git a/commands/random-res/cat-fact.js b/commands/random-res/cat-fact.js deleted file mode 100644 index ce611f8e..00000000 --- a/commands/random-res/cat-fact.js +++ /dev/null @@ -1,18 +0,0 @@ -const Command = require('../../structures/Command'); -const facts = require('../../assets/json/cat-fact'); - -module.exports = class CatFactCommand extends Command { - constructor(client) { - super(client, { - name: 'cat-fact', - aliases: ['neko-fact', 'kitty-fact'], - group: 'random-res', - memberName: 'cat-fact', - description: 'Responds with a random cat fact.' - }); - } - - run(msg) { - return msg.say(facts[Math.floor(Math.random() * facts.length)]); - } -}; diff --git a/commands/random-res/dog-fact.js b/commands/random-res/dog-fact.js deleted file mode 100644 index 96b999aa..00000000 --- a/commands/random-res/dog-fact.js +++ /dev/null @@ -1,18 +0,0 @@ -const Command = require('../../structures/Command'); -const facts = require('../../assets/json/dog-fact'); - -module.exports = class DogFactCommand extends Command { - constructor(client) { - super(client, { - name: 'dog-fact', - aliases: ['puppy-fact'], - group: 'random-res', - memberName: 'dog-fact', - description: 'Responds with a random dog fact.' - }); - } - - run(msg) { - return msg.say(facts[Math.floor(Math.random() * facts.length)]); - } -}; diff --git a/package.json b/package.json index 6c5c52ea..e98073d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "125.0.1", + "version": "126.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {