snekfetch 4.0.0

This commit is contained in:
Daniel Odendahl Jr
2018-02-26 22:10:01 +00:00
parent a4767134e5
commit 9aaf21913b
22 changed files with 45 additions and 40 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, raw } = await snekfetch.get(`https://http.cat/${code}.jpg`);
if (raw.toString().startsWith('<!DOCTYPE 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!`);