mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 01:57:54 +02:00
Fix Error Messages
This commit is contained in:
@@ -20,9 +20,9 @@ module.exports = class CatCommand extends Command {
|
||||
const { body } = await snekfetch
|
||||
.get('http://random.cat/meow');
|
||||
return msg.say({ files: [body.file] })
|
||||
.catch(err => msg.say(err));
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
} catch (err) {
|
||||
return msg.say(err);
|
||||
return msg.say('An Error Occurred.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ module.exports = class DogCommand extends Command {
|
||||
const { body } = await snekfetch
|
||||
.get('https://random.dog/woof.json');
|
||||
return msg.say({ files: [body.url] })
|
||||
.catch(err => msg.say(err));
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
} catch (err) {
|
||||
return msg.say(err);
|
||||
return msg.say('An Error Occurred.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,6 +18,6 @@ module.exports = class XiaoCommand extends Command {
|
||||
return msg.say('This Command requires the `Attach Files` Permission.');
|
||||
const xiao = Math.floor(Math.random() * 10) + 1;
|
||||
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', `xiaopai${xiao}.png`)] })
|
||||
.catch(err => msg.say(err));
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,16 +32,16 @@ module.exports = class XKCDCommand extends Command {
|
||||
const current = await snekfetch
|
||||
.get('https://xkcd.com/info.0.json');
|
||||
if (type === 'today') return msg.say({ files: [current.body.img] })
|
||||
.catch(err => msg.say(err));
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
else {
|
||||
const random = Math.floor(Math.random() * current.body.num) + 1;
|
||||
const { body } = await snekfetch
|
||||
.get(`https://xkcd.com/${random}/info.0.json`);
|
||||
return msg.say({ files: [body.img] })
|
||||
.catch(err => msg.say(err));
|
||||
.catch(() => msg.say('An Error Occurred while sending the image.'));
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.say(err);
|
||||
return msg.say('An Error Occurred.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user