mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
Convert everything to superagent properly
This commit is contained in:
@@ -21,10 +21,10 @@ module.exports = class HttpCatCommand extends Command {
|
||||
|
||||
async run(msg, { code }) {
|
||||
try {
|
||||
const { body, headers } = await request.get(`https://http.cat/${code}.jpg`);
|
||||
if (headers['content-type'] === 'text/html') return msg.say('Could not find any results.');
|
||||
const { body } = await request.get(`https://http.cat/${code}.jpg`);
|
||||
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