From 396905c5d9540d942f33b5885ab5299d1cfce488 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Wed, 20 Feb 2019 17:56:58 +0000 Subject: [PATCH] Random Bird Command --- README.md | 3 ++- commands/random/bird.js | 30 ++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 commands/random/bird.js diff --git a/README.md b/README.md index 935b2d3d..2cf8f6db 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Xiao is a Discord bot coded in JavaScript with 7. Run `npm i -g pm2` to install PM2. 8. Run `pm2 start Xiao.js --name xiao` to run the bot. -## Commands (338) +## Commands (339) ### Utility: * **eval:** Executes JavaScript code. @@ -78,6 +78,7 @@ Xiao is a Discord bot coded in JavaScript with * **8-ball:** Asks your question to the Magic 8 Ball. * **advice:** Responds with a random bit of advice. +* **bird:** Responds with a random image of a bird. * **cat-fact:** Responds with a random cat fact. * **cat:** Responds with a random cat image. * **charlie-charlie:** Asks your question to Charlie. diff --git a/commands/random/bird.js b/commands/random/bird.js new file mode 100644 index 00000000..876485ea --- /dev/null +++ b/commands/random/bird.js @@ -0,0 +1,30 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class BirdCommand extends Command { + constructor(client) { + super(client, { + name: 'bird', + aliases: ['birb'], + group: 'random', + memberName: 'bird', + description: 'Responds with a random image of a bird.', + clientPermissions: ['ATTACH_FILES'] + }); + } + + async run(msg) { + try { + const { body } = await request + .get('https://shibe.online/api/birds') + .query({ + count: 1, + urls: true, + httpsUrls: true + }); + return msg.say({ files: [body[0]] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index f08e11e5..dfcddab8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "101.7.0", + "version": "101.8.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {