diff --git a/README.md b/README.md index 5a1a746a..5ba86d72 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can invite the bot to your server using Be sure to also join the [home server](https://discord.gg/sbMe32W) for information and support. -## Commands (302) +## Commands (303) ### Utility: * **prefix**: Shows or sets the command prefix. @@ -136,6 +136,7 @@ information and support. * **google**: Searches Google for your query. * **gravatar**: Responds with the Gravatar for an email. * **http-cat**: Responds with a cat for an HTTP status code. +* **http-dog**: Responds with a dog for an HTTP status code. * **imgur**: Searches Imgur for your query. * **itunes**: Searches iTunes for your query. * **jisho**: Defines a word, but with Japanese. diff --git a/commands/search/http-dog.js b/commands/search/http-dog.js new file mode 100644 index 00000000..5983f753 --- /dev/null +++ b/commands/search/http-dog.js @@ -0,0 +1,31 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class HttpDogCommand extends Command { + constructor(client) { + super(client, { + name: 'http-dog', + group: 'search', + memberName: 'http-dog', + description: 'Responds with a dog for an HTTP status code.', + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'code', + prompt: 'What code do you want to get the dog of?', + type: 'integer' + } + ] + }); + } + + async run(msg, { code }) { + try { + const { body, headers } = await request.get(`https://httpstatusdogs.com/img/${code}.jpg`); + if (headers['content-type'].includes('text/html')) return msg.say('Could not find any results.'); + return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 516b7ea5..21800878 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "80.0.0", + "version": "80.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {