mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 06:37:32 +02:00
Fix
This commit is contained in:
@@ -21,10 +21,10 @@ module.exports = class HTTPCatCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { code }) {
|
async run(msg, { code }) {
|
||||||
try {
|
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` }] });
|
return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] });
|
||||||
} catch (err) {
|
} 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!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user