forked from syntaxbullet/aurorabot
- Create withCommandErrorHandling utility in bot/lib/commandUtils.ts - Migrate economy commands: daily, exam, pay, trivia - Migrate inventory command: use - Migrate admin/moderation commands: warn, case, cases, clearwarning, warnings, note, notes, create_color, listing, webhook, refresh, terminal, featureflags, settings, prune - Add 9 unit tests for the utility - Update AGENTS.md with new recommended error handling pattern
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { createCommand } from "@shared/lib/utils";
|
|
import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from "discord.js";
|
|
import { moderationService } from "@shared/modules/moderation/moderation.service";
|
|
import { getCaseEmbed, getModerationErrorEmbed } from "@/modules/moderation/moderation.view";
|
|
import { withCommandErrorHandling } from "@lib/commandUtils";
|
|
|
|
export const moderationCase = createCommand({
|
|
data: new SlashCommandBuilder()
|
|
.setName("case")
|
|
.setDescription("View details of a specific moderation case")
|
|
.addStringOption(option =>
|
|
option
|
|
.setName("case_id")
|
|
.setDescription("The case ID (e.g., CASE-0001)")
|
|
.setRequired(true)
|
|
)
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
|
|
|
execute: async (interaction) => {
|
|
await withCommandErrorHandling(
|
|
interaction,
|
|
async () => {
|
|
const caseId = interaction.options.getString("case_id", true).toUpperCase();
|
|
|
|
// Validate case ID format
|
|
if (!caseId.match(/^CASE-\d+$/)) {
|
|
await interaction.editReply({
|
|
embeds: [getModerationErrorEmbed("Invalid case ID format. Expected format: CASE-0001")]
|
|
});
|
|
return;
|
|
}
|
|
|
|
// Get the case
|
|
const moderationCase = await moderationService.getCaseById(caseId);
|
|
|
|
if (!moderationCase) {
|
|
await interaction.editReply({
|
|
embeds: [getModerationErrorEmbed(`Case **${caseId}** not found.`)]
|
|
});
|
|
return;
|
|
}
|
|
|
|
// Display the case
|
|
await interaction.editReply({
|
|
embeds: [getCaseEmbed(moderationCase)]
|
|
});
|
|
},
|
|
{ ephemeral: true }
|
|
);
|
|
}
|
|
});
|