Catch errors on message send (Fix #4)

This commit is contained in:
Skylar Grant 2023-09-02 19:33:32 -04:00
parent 4f576f9b5d
commit d268f52237

10
main.js
View File

@ -69,7 +69,7 @@ client.on('interactionCreate', async interaction => {
if (client.slashCommands.has(commandName)) { if (client.slashCommands.has(commandName)) {
client.slashCommands.get(commandName).execute(interaction); client.slashCommands.get(commandName).execute(interaction);
} else { } else {
interaction.reply('Sorry, I don\'t have access to that command.'); interaction.reply('Sorry, I don\'t have access to that command.').catch(e => console.err(e));
console.error('Slash command attempted to run but not found: ' + commandName); console.error('Slash command attempted to run but not found: ' + commandName);
} }
} }
@ -79,7 +79,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("Oops! Something went wrong!")); interaction.channel.send(fn.builders.errorEmbed("Oops! Something went wrong!")).catch(e => console.err(e));
}); });
break; break;
case 'deleteping': case 'deleteping':
@ -103,10 +103,10 @@ client.on('interactionCreate', async interaction => {
} }
} catch(err) { } catch(err) {
if (err === "Guild doesn't exist in database!") { if (err === "Guild doesn't exist in database!") {
interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild)); interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild)).catch(e => console.err(e));
console.error(err); console.error(err);
} else { } else {
interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening."); interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening.").catch(e => console.err(e));
console.error(err); console.error(err);
} }
} }
@ -117,7 +117,7 @@ client.on('messageUpdate', async (oldMessage, message) => {
await fn.messages.updateHandler(message).catch(async e => { await fn.messages.updateHandler(message).catch(async e => {
switch (e) { switch (e) {
case strings.error.noCompareMessage: case strings.error.noCompareMessage:
await message.channel.send(strings.error.noCompareMessage); await message.channel.send(strings.error.noCompareMessage).catch(e => console.err(e));
break; break;
default: default:
break; break;