From b0a9a6a42c711ec60c6c4db44590ffe6ce80ecab Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 19 Feb 2023 19:37:56 -0500 Subject: [PATCH] Improved error handling --- data/strings.json | 5 ++++- modules/functions.js | 4 ++-- slash-commands/setup.js | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/data/strings.json b/data/strings.json index a595ff7..ed7f0a6 100755 --- a/data/strings.json +++ b/data/strings.json @@ -20,6 +20,8 @@ "embeds": { "footer": "Silvanus is not affiliated with Grow A Tree or Limbo Labs", "color": "0x55FF55", + "errorTitle": "Oops!", + "errorPrefix": "There seems to have been a problem.", "waterColor": "0x5555FF", "fruitColor": "0xCC5555", "waterTitle": "Water Notification", @@ -48,7 +50,8 @@ "supportServer": "https://discord.gg/g5JRGn7PxU" }, "error": { - "noGuild": "Setup has not been completed yet. Try running or " + "noGuild": "Setup has not been completed yet. Try running or ", + "invalidSubcommand": "Invalid subcommand detected." }, "status": { "treeAndLeaderboard": "Tree and leaderboard messages were both found, setup is complete. Run to verify. Run to get started!", diff --git a/modules/functions.js b/modules/functions.js index 9bbb07f..d6b612d 100755 --- a/modules/functions.js +++ b/modules/functions.js @@ -157,8 +157,8 @@ const functions = { errorEmbed(content) { const embed = new EmbedBuilder() .setColor(0xFF0000) - .setTitle('Error!') - .setDescription("Error: " + content) + .setTitle(strings.embeds.errorTitle) + .setDescription(`${strings.embeds.errorPrefix}\n${content}`) .setFooter({ text: `v${package.version} - ${strings.embeds.footer}` }); const messageContents = { embeds: [embed], ephemeral: true }; return messageContents; diff --git a/slash-commands/setup.js b/slash-commands/setup.js index b24133e..4feb841 100755 --- a/slash-commands/setup.js +++ b/slash-commands/setup.js @@ -88,6 +88,7 @@ module.exports = { } break; default: + await interaction.editReply(fn.builders.errorEmbed(strings.error.invalidSubcommand)).catch(e => console.error(e)); break; } },