const { SlashCommandBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, EmbedBuilder } = require('discord.js'); const User = require('../models/User'); module.exports = { data: new SlashCommandBuilder() .setName('profile') .setDescription('View or create your detective profile'), async execute(interaction) { const userId = interaction.user.id; const username = interaction.user.username; const user = await User.findOne({ userId }); if (!user) { const modal = new ModalBuilder() .setCustomId('profileCreate') .setTitle('Create Your Detective Profile'); const nameInput = new TextInputBuilder() .setCustomId('name') .setLabel('Detective Name') .setStyle(TextInputStyle.Short) .setMinLength(3) .setMaxLength(30) .setRequired(true) .setPlaceholder('e.g. John Noir'); const specialtyInput = new TextInputBuilder() .setCustomId('specialty') .setLabel('Specialty (Optional)') .setStyle(TextInputStyle.Short) .setRequired(false) .setPlaceholder('Interrogator, Analyst...'); const bioInput = new TextInputBuilder() .setCustomId('bio') .setLabel('Short Bio (Optional)') .setStyle(TextInputStyle.Paragraph) .setRequired(false) .setPlaceholder('Ex-cop turned PI with a chip on his shoulder.'); modal.addComponents( new ActionRowBuilder().addComponents(nameInput), new ActionRowBuilder().addComponents(specialtyInput), new ActionRowBuilder().addComponents(bioInput) ); return interaction.showModal(modal); } const embed = new EmbedBuilder() .setTitle(`🕵️ ${user.detectiveName}`) .setDescription(user.bio || '_No bio set._') .addFields( { name: '🪙 Coins', value: `${user.coins}`, inline: true }, { name: '🧠 XP', value: `${user.xp}`, inline: true }, { name: '🎯 Specialty', value: user.specialty || '_None_', inline: true }, { name: '✅ Solved', value: `${user.solved}`, inline: true }, { name: '❌ Failed', value: `${user.failed}`, inline: true } ) .setColor(0x2ecc71) .setFooter({ text: 'Use /setprofile to edit your name, bio, or specialty.' }) .setTimestamp(); return interaction.reply({ embeds: [embed], ephemeral: true }); } };