feat(commands): improve error feedback for economy and admin commands

This commit is contained in:
syntaxbullet
2025-12-22 12:59:46 +01:00
parent fbcac51370
commit 0dea266a6d
4 changed files with 42 additions and 27 deletions

View File

@@ -2,6 +2,7 @@ import { createCommand } from "@/lib/utils";
import { SlashCommandBuilder } from "discord.js";
import { userService } from "@/modules/user/user.service";
import { createErrorEmbed, createSuccessEmbed } from "@lib/embeds";
import { UserError } from "@/lib/errors";
import { userTimers, users } from "@/db/schema";
import { eq, and, sql } from "drizzle-orm";
import { DrizzleClient } from "@/lib/DrizzleClient";
@@ -179,8 +180,12 @@ export const exam = createCommand({
});
} catch (error: any) {
console.error("Exam command error:", error);
await interaction.editReply({ embeds: [createErrorEmbed("An error occurred while processing your exam.")] });
if (error instanceof UserError) {
await interaction.reply({ embeds: [createErrorEmbed(error.message)], ephemeral: true });
} else {
console.error("Error in exam command:", error);
await interaction.reply({ embeds: [createErrorEmbed("An unexpected error occurred.")], ephemeral: true });
}
}
}
});