Catch Yoda Error

This commit is contained in:
Daniel Odendahl Jr
2017-08-20 20:59:45 +00:00
parent 841cae7179
commit eac9f9bf10
2 changed files with 10 additions and 6 deletions
+9 -5
View File
@@ -26,10 +26,14 @@ module.exports = class YodaCommand extends Command {
async run(msg, args) {
const { sentence } = args;
const { text } = await snekfetch
.get('https://yoda.p.mashape.com/yoda')
.query({ sentence })
.set({ 'X-Mashape-Key': MASHAPE_KEY });
return msg.say(text);
try {
const { text } = await snekfetch
.get('https://yoda.p.mashape.com/yoda')
.query({ sentence })
.set({ 'X-Mashape-Key': MASHAPE_KEY });
return msg.say(text);
} catch (err) {
return msg.say(`Oh no, Yoda's being a jerk and not working again: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "30.7.1",
"version": "30.7.2",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {