Fix horoscope, new cat api (random.cat bork), move groups

This commit is contained in:
Daniel Odendahl Jr
2018-04-25 20:58:12 +00:00
parent 3dc48df4a9
commit 76860705da
7 changed files with 13 additions and 9 deletions
+6 -2
View File
@@ -1,5 +1,6 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { THE_CAT_API_KEY } = process.env;
module.exports = class CatCommand extends Command {
constructor(client) {
@@ -15,8 +16,11 @@ module.exports = class CatCommand extends Command {
async run(msg) {
try {
const { body } = await snekfetch.get('http://aws.random.cat/meow');
return msg.say({ files: [body.file] });
const { body, headers } = await snekfetch
.get('http://thecatapi.com/api/images/get')
.query({ api_key: THE_CAT_API_KEY });
const format = headers['content-type'].replace(/image\//i, '');
return msg.say({ files: [{ attachment: body, name: `cat.${format}` }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}