Illegal, Karen, better ping

This commit is contained in:
Daniel Odendahl Jr
2018-03-19 22:41:40 +00:00
parent 3842db73a1
commit 1877c53674
8 changed files with 92 additions and 6 deletions
+2 -2
View File
@@ -21,8 +21,8 @@ module.exports = class HTTPCatCommand extends Command {
async run(msg, { code }) {
try {
const { body, text } = await snekfetch.get(`https://http.cat/${code}.jpg`);
if (text.startsWith('<!DOCTYPE html>')) return msg.say('Could not find any results.');
const { body, headers } = await snekfetch.get(`https://http.cat/${code}.jpg`);
if (headers['content-type'] === '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!`);