Add try/catch to command execution
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful

This commit is contained in:
Ethan Lane 2024-02-23 18:18:40 +00:00
parent 9a278b3dc1
commit 0517a48549
2 changed files with 14 additions and 2 deletions

View file

@ -12,6 +12,12 @@ export default class Button {
return;
}
item.Event.execute(interaction);
try {
item.Event.execute(interaction);
} catch (e) {
console.error(e);
await interaction.reply("An error occurred while executing the event");
}
}
}

View file

@ -22,6 +22,12 @@ export default class ChatInputCommand {
itemToUse = itemForServer;
}
itemToUse.Command.execute(interaction);
try {
itemToUse.Command.execute(interaction);
} catch (e) {
console.error(e);
await interaction.reply("An error occurred while executing the command");
}
}
}