From 8045d591c0f5b15c4f8e62fc1d9461a45068cf66 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 19 Feb 2018 22:25:38 +0000 Subject: [PATCH] HTTPCat --- commands/search/http-cat.js | 31 +++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 commands/search/http-cat.js diff --git a/commands/search/http-cat.js b/commands/search/http-cat.js new file mode 100644 index 00000000..2707d853 --- /dev/null +++ b/commands/search/http-cat.js @@ -0,0 +1,31 @@ +const { Command } = require('discord.js-commando'); +const snekfetch = require('snekfetch'); + +module.exports = class HTTPCatCommand extends Command { + constructor(client) { + super(client, { + name: 'http-cat', + group: 'search', + memberName: 'http-cat', + description: 'Responds with a cat for an HTTP status code.', + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'code', + prompt: 'What code do you want to get the cat of?', + type: 'integer' + } + ] + }); + } + + async run(msg, { code }) { + try { + const { body } = await snekfetch.get(`https://http.cat/${code}.jpg`); + return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] }); + } catch (err) { + if (err.status === 404) return msg.say('Could not find any results.'); + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 57d03d3c..91eb5b72 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "65.2.3", + "version": "65.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {