Begin migrating away from stupid "Oh no, an error occurred!"

This commit is contained in:
Dragon Fire
2024-03-29 23:57:49 -04:00
parent 067545b818
commit 0b807767d1
130 changed files with 1692 additions and 2190 deletions
+4 -8
View File
@@ -49,14 +49,10 @@ module.exports = class CurrencyCommand extends Command {
if (!this.currencies[base]) return msg.say('You provided an invalid base currency code.');
if (!this.currencies[target]) return msg.say('You provided an invalid target currency code.');
if (base === target) return msg.say(`Converting ${base} to ${target} is the same value, dummy.`);
try {
const rate = await this.fetchRate(base, target);
const baseName = this.currencies[base];
const targetName = this.currencies[target];
return msg.say(`${formatNumber(amount)} ${baseName} is ${formatNumber(amount * rate)} ${targetName}.`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
const rate = await this.fetchRate(base, target);
const baseName = this.currencies[base];
const targetName = this.currencies[target];
return msg.say(`${formatNumber(amount)} ${baseName} is ${formatNumber(amount * rate)} ${targetName}.`);
}
async fetchCurrencies() {