Improved error handling?

This commit is contained in:
Skylar Grant 2023-07-06 19:04:13 -04:00
parent c0cba3e14e
commit 25859d364d
2 changed files with 49 additions and 38 deletions

View File

@ -53,7 +53,7 @@
"supportServer": "https://discord.gg/g5JRGn7PxU" "supportServer": "https://discord.gg/g5JRGn7PxU"
}, },
"error": { "error": {
"noGuild": "Setup has not been completed yet. Try running </setup:1065407649363005561> or </help setup:1065346941166297129>", "noGuild": "I was unable to find an entry for your server in the database. Try using the `/setup rolemenu` or `/relay` commands to generate a new entry. If that fails, try `/setup reset`, then kick me and re-add me. If you continue receiving this error, join the Support Server or DM @vfsh",
"invalidSubcommand": "Invalid subcommand detected.", "invalidSubcommand": "Invalid subcommand detected.",
"noTreeMessage": "</tree:0> - Make sure you've sent or refreshed a Tree recently.", "noTreeMessage": "</tree:0> - Make sure you've sent or refreshed a Tree recently.",
"noLeaderboardMessage": "</top trees:0> - Make sure you've sent or refreshed the Tallest Trees leaderboard recently.", "noLeaderboardMessage": "</top trees:0> - Make sure you've sent or refreshed the Tallest Trees leaderboard recently.",

13
main.js
View File

@ -47,6 +47,7 @@ client.once('ready', async () => {
// slash-commands // slash-commands
client.on('interactionCreate', async interaction => { client.on('interactionCreate', async interaction => {
try {
if (interaction.isCommand()) { if (interaction.isCommand()) {
if (isDev) { if (isDev) {
// console.log(interaction); // console.log(interaction);
@ -66,7 +67,7 @@ client.on('interactionCreate', async interaction => {
case 'refresh': case 'refresh':
// console.log(JSON.stringify(interaction)); // console.log(JSON.stringify(interaction));
await fn.refresh(interaction).catch(err => { await fn.refresh(interaction).catch(err => {
interaction.channel.send(fn.builders.errorEmbed(err)); interaction.channel.send(fn.builders.errorEmbed("Oops! Something went wrong!"));
}); });
break; break;
case 'deleteping': case 'deleteping':
@ -88,6 +89,16 @@ client.on('interactionCreate', async interaction => {
break; break;
} }
} }
} catch(err) {
if (err === "Guild doesn't exist in database!") {
interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild));
console.error(err);
} else {
interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening.");
console.error(err);
}
}
}); });
client.on('messageUpdate', async (oldMessage, message) => { client.on('messageUpdate', async (oldMessage, message) => {