mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 08:12:04 +02:00
Fix
This commit is contained in:
@@ -21,10 +21,10 @@ module.exports = class HTTPCatCommand extends Command {
|
||||
|
||||
async run(msg, { code }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://http.cat/${code}.jpg`);
|
||||
const { body, text } = await snekfetch.get(`https://http.cat/${code}.jpg`);
|
||||
if (text.startsWith('<!DOCTYPE html>')) return msg.say('Could not find any results.');
|
||||
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!`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user