import { createCommand } from "@shared/lib/utils"; import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js"; import { moderationService } from "@shared/modules/moderation/moderation.service"; import { getWarningsEmbed } from "@/modules/moderation/moderation.view"; import { withCommandErrorHandling } from "@lib/commandUtils"; export const warnings = createCommand({ data: new SlashCommandBuilder() .setName("warnings") .setDescription("View active warnings for a user") .addUserOption(option => option .setName("user") .setDescription("The user to check warnings for") .setRequired(true) ) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), execute: async (interaction) => { await withCommandErrorHandling( interaction, async () => { const targetUser = interaction.options.getUser("user", true); // Get active warnings for the user const activeWarnings = await moderationService.getUserWarnings(targetUser.id); // Display the warnings await interaction.editReply({ embeds: [getWarningsEmbed(activeWarnings, targetUser.username)] }); }, { ephemeral: true } ); } });