fix: user error now results in user friendly message

This commit is contained in:
TrèsAbhi committed 2023-11-01 11:21:30 -05:00
1 parent dfba8bd15f
commit d991be4934
1 file changed
+7 -8
@@ -20,7 +20,6 @@ export default async function handleChatInputCommand(
await interaction.deferReply();
try {
if (registry.inPreview && interaction.guildId !== discord.tres_guild_id) {
interaction.editReply({
embeds: [
@@ -34,6 +33,7 @@ export default async function handleChatInputCommand(
return;
}
try {
const returnable = await registry.handler(interaction);
if (registry.handlesInteraction) return;
@@ -56,21 +56,20 @@ export default async function handleChatInputCommand(
),
];
if (!(error instanceof UserError)) {
console.error(interaction.commandName, error);
if (error instanceof UserError) {
interaction.editReply({
embeds: [
embedNegative(
(error as Error).message,
`${
(error as Error).cause ?? 'No further information is available.'
}`,
error.message,
(error.cause as string | undefined) ??
'No further information is available.',
),
],
components,
});
} else {
console.error(interaction.commandName, error);
interaction.editReply({
embeds: [
embedNegative(