HTTP Duck Command

This commit is contained in:
Dragon Fire
2020-01-16 18:57:46 -05:00
parent f2d4c42a7d
commit 1ac744141f
3 changed files with 43 additions and 2 deletions
+3 -1
View File
@@ -91,7 +91,7 @@ Xiao is a Discord bot coded in JavaScript with
## Commands
Total: 353
Total: 354
### Utility:
@@ -236,6 +236,7 @@ Total: 353
* **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.
* **http-duck:** Responds with a duck for an HTTP status code.
* **imgur:** Searches Imgur for your query.
* **itunes:** Searches iTunes for your query.
* **jisho:** Defines a word, but with Japanese.
@@ -847,6 +848,7 @@ here.
* shower-thought (Shower Thought Data)
- [Random-d.uk](https://random-d.uk/)
* duck ([API](https://random-d.uk/api))
* http-duck ([API](https://random-d.uk/http))
- [random.cat](https://random.cat/)
* cat (API)
- [RandomFox](https://randomfox.ca/)
+39
View File
@@ -0,0 +1,39 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
module.exports = class HttpDuckCommand extends Command {
constructor(client) {
super(client, {
name: 'http-duck',
group: 'search',
memberName: 'http-duck',
description: 'Responds with a duck for an HTTP status code.',
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Random-d.uk',
url: 'https://random-d.uk/',
reason: 'API',
reasonURL: 'https://random-d.uk/http'
}
],
args: [
{
key: 'code',
prompt: 'What code do you want to get the duck of?',
type: 'integer'
}
]
});
}
async run(msg, { code }) {
try {
const { body, headers } = await request.get(`https://random-d.uk/api/http/${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!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "110.0.3",
"version": "110.1.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {