pushing exception handling

This commit is contained in:
John Facey
2022-06-21 22:02:36 -05:00
parent 24b3700775
commit 462dca403f
7 changed files with 143 additions and 122 deletions

View File

@@ -1,13 +1,15 @@
var libFlayer = require("../libFlayer.js");
const quote_url = "https://zenquotes.io/api/quotes/";
module.exports = {
name: 'quote',
description: 'Quote!',
async execute(message) {
var quotes = await libFlayer.getQuotes(quote_url);
var selectedQuote = Math.floor(Math.random() * quotes.length);
message.reply(quotes[selectedQuote].q + " - " + quotes[selectedQuote].a);
try {
var quotes = await libFlayer.getQuotes(quote_url);
var selectedQuote = Math.floor(Math.random() * quotes.length);
message.reply(quotes[selectedQuote].q + " - " + quotes[selectedQuote].a);
} catch (e) {
message.reply(e.toString());
}
}
};