mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Finish removing "Oh no, an error occurred"
This commit is contained in:
+10
-14
@@ -30,19 +30,15 @@ module.exports = class DefineCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { word }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://www.dictionaryapi.com/api/v3/references/collegiate/json/${word}`)
|
||||
.query({ key: WEBSTER_KEY });
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
const data = body[0];
|
||||
if (typeof data === 'string') return msg.say(`Could not find any results. Did you mean **${data}**?`);
|
||||
return msg.say(stripIndents`
|
||||
**${data.meta.stems[0]}** (${data.fl})
|
||||
${data.shortdef.map((definition, i) => `(${i + 1}) ${definition}`).join('\n')}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request
|
||||
.get(`https://www.dictionaryapi.com/api/v3/references/collegiate/json/${word}`)
|
||||
.query({ key: WEBSTER_KEY });
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
const data = body[0];
|
||||
if (typeof data === 'string') return msg.say(`Could not find any results. Did you mean **${data}**?`);
|
||||
return msg.say(stripIndents`
|
||||
**${data.meta.stems[0]}** (${data.fl})
|
||||
${data.shortdef.map((definition, i) => `(${i + 1}) ${definition}`).join('\n')}
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user