From cf3102cbc597b0d332e42e40840243cf921d651f Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Mon, 31 Jul 2023 12:11:23 +0200 Subject: [PATCH] Inform enduser on failed interaction --- src/interactionManager.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/interactionManager.ts b/src/interactionManager.ts index df7895b..5187db6 100644 --- a/src/interactionManager.ts +++ b/src/interactionManager.ts @@ -30,7 +30,16 @@ export default class CommandManager { ) { const foundCommand = this.commands.find((command) => command.name === interaction.commandName ); if (!foundCommand) throw new Error(`Unknown command received (${interaction.commandName}). Did you forgot to push updated commands?`); - foundCommand.execute(interaction); + foundCommand.execute(interaction).catch(e => { + interaction.reply({ + embeds: [{ + color: 0xff0000, + description: `Failed to perform interaction:\n\`${e}\``, + }] + }).catch(() => {/* GRACEFAIL: We're still logging the issue that happened to the console */}); + console.error(`Failed to perform interaction: ${interaction.commandName}`); + console.error(e); + }); return; } if (interaction.isAutocomplete()) {