From 6c4b7788344d57645f745a23c1833712d21c0684 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Thu, 4 Jun 2020 12:27:04 -0400 Subject: [PATCH] Bunny Command --- README.md | 5 ++++- commands/random-img/bunny.js | 33 +++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 commands/random-img/bunny.js diff --git a/README.md b/README.md index c7eb206a..6753642b 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 455 +Total: 456 ### Utility: @@ -314,6 +314,7 @@ Total: 455 ### Random Image: * **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. * **duck:** Responds with a random duck image. @@ -843,6 +844,8 @@ here. * bulbapedia ([API](https://bulbapedia.bulbagarden.net/w/api.php)) - [Bulletin of the Atomic Scientists](https://thebulletin.org/) * doomsday-clock ([Doomsday Clock Data](https://thebulletin.org/doomsday-clock/current-time/)) +- [bunnies.io](https://www.bunnies.io/) + * bunny (API) - [calzoneman](https://github.com/calzoneman) * dec-talk ([API](https://github.com/calzoneman/aeiou)) - [Capcom](http://www.capcom.com/us/) diff --git a/commands/random-img/bunny.js b/commands/random-img/bunny.js new file mode 100644 index 00000000..7edb14d3 --- /dev/null +++ b/commands/random-img/bunny.js @@ -0,0 +1,33 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class BunnyCommand extends Command { + constructor(client) { + super(client, { + name: 'bunny', + aliases: ['bun', 'rabbit'], + group: 'random-img', + memberName: 'bunny', + description: 'Responds with a random image of a bunny.', + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'bunnies.io', + url: 'https://www.bunnies.io/', + reason: 'API' + } + ] + }); + } + + async run(msg) { + try { + const { body } = await request + .get('https://api.bunnies.io/v2/loop/random/') + .query({ media: 'gif,png' }); + return msg.say({ files: [body.media.gif || body.media.poster] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 4dd1b76c..b0d2b4a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.0.0", + "version": "116.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {