Skip to content

Commit

Permalink
fix: catch more errors when executing commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tippfehlr committed Aug 30, 2024
1 parent 242324a commit a1388b5
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/modules/commandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,26 @@ export default class CommandHandler {
command.execute(interaction);
} catch (error) {
log.error(error, 'Error while executing command' + command.data.name);
await interaction.reply({
content: __({
phrase: 'There was an error while executing this command!',
locale: getLang(interaction),
}),
ephemeral: true,
});
try {
if (interaction.replied) {
await interaction.editReply({
content: __({
phrase: 'There was an error while executing this command!',
locale: getLang(interaction),
}),
});
} else {
await interaction.reply({
content: __({
phrase: 'There was an error while executing this command!',
locale: getLang(interaction),
}),
ephemeral: true,
});
}
} catch (error) {
log.error(error, 'Error replying');
}
}
});
}
Expand Down

0 comments on commit a1388b5

Please sign in to comment.