import { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits, ChatInputCommandInteraction } from 'discord.js'; import { SlashCommand } from '../../utils/types'; import { context } from '../../config/context'; const TYPE_LABELS: Record = { warn: 'Warnungen', mute: 'Mutes', timeout: 'Timeouts', kick: 'Kicks', ban: 'Bans', tempban: 'Tempbans', note: 'Notizen', watchlist_add: 'Watchlist (hinzugefügt)', watchlist_remove: 'Watchlist (entfernt)' }; const command: SlashCommand = { guildOnly: true, data: new SlashCommandBuilder() .setName('case') .setDescription('Zeigt oder ergänzt die Mod-Akte eines Nutzers.') .addSubcommand((sub) => sub .setName('view') .setDescription('Zeigt die Mod-Akte eines Nutzers.') .addUserOption((opt) => opt.setName('user').setDescription('Nutzer').setRequired(true)) ) .addSubcommand((sub) => sub .setName('note') .setDescription('Fügt eine interne Notiz zur Akte hinzu.') .addUserOption((opt) => opt.setName('user').setDescription('Nutzer').setRequired(true)) .addStringOption((opt) => opt.setName('body').setDescription('Notiz').setRequired(true)) ) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers), async execute(interaction: ChatInputCommandInteraction) { if (!interaction.guild) return; const sub = interaction.options.getSubcommand(); const user = interaction.options.getUser('user', true); if (sub === 'note') { const body = interaction.options.getString('body', true); await context.modCases.addNote(interaction.guild.id, user.id, interaction.user.id, interaction.user.tag, body); await interaction.reply({ content: `Notiz zur Akte von ${user.tag} hinzugefügt.`, ephemeral: true }); return; } const data = await context.modCases.getCase(interaction.guild.id, user.id); const watched = context.watchlist.isWatched(interaction.guild.id, user.id); const embed = new EmbedBuilder() .setTitle(`Mod-Akte: ${user.tag}`) .setColor(watched ? 0xeab308 : 0x7289da) .addFields( ...Object.entries(TYPE_LABELS).map(([type, label]) => ({ name: label, value: String(data.counts[type] || 0), inline: true })), { name: 'Tickets erstellt', value: String(data.ticketCount), inline: true }, { name: 'Automod-Verstöße', value: String(data.automodStrikes), inline: true }, { name: 'Beobachtungsliste', value: watched ? 'Ja' : 'Nein', inline: true } ); const recent = data.cases.slice(0, 10); if (recent.length) { embed.addFields({ name: 'Letzte Einträge', value: recent .map((c) => `**${TYPE_LABELS[c.type] || c.type}** — ${c.reason || 'Kein Grund'} (${c.moderatorTag}, ${c.createdAt.toLocaleDateString('de-DE')})`) .join('\n') .slice(0, 1024) }); } await interaction.reply({ embeds: [embed], ephemeral: true }); } }; export default command;