mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 02:15:10 +02:00
Better Error Handling
This commit is contained in:
@@ -28,13 +28,14 @@ module.exports = class DefineCommand extends Command {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${process.env.WORDNIK_KEY}`);
|
||||
if(body.length === 0) throw new Error('No Results.');
|
||||
const embed = new RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setTitle(body[0].word)
|
||||
.setDescription(body[0].text);
|
||||
return msg.embed(embed);
|
||||
} catch(err) {
|
||||
return msg.say('An Error Occurred. The word may not have been found.');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user