import { type Client, type ChatInputCommandInteraction, SlashCommandBuilder, } from "discord.js"; import { db, moderators } from "@/database"; import config from "@/config"; const pronounTypes = { subjective: "Subject (e.g., **They** are a moderator)", objective: "Object (e.g., Send **them** a message)", "possessive-determiner": "Possessive Determiner (e.g., This is **their** post)", "possessive-pronoun": "Possessive Pronoun (e.g., The post is **theirs**)", reflexive: "Reflexive (e.g., They assigned it to **themself**)", }; const command = new SlashCommandBuilder() .setName("woke") .setDescription("Set your pronouns."); Object.entries(pronounTypes).forEach(([key, description]) => { command.addStringOption((option) => option.setName(key).setDescription(description).setRequired(true), ); }); command.addUserOption((option) => option .setName("user") .setRequired(false) .setDescription("The user to set pronouns for."), ); async function execute( _client: Client, interaction: ChatInputCommandInteraction, ) { const id = interaction.options.getUser("user")?.id || interaction.user.id; if ( interaction.options.getUser("user") && interaction.user.id !== config.developerId ) { await interaction.reply({ content: "You cannot use this command.", ephemeral: true, }); return; } const pronounData = { subjective: interaction.options.getString("subjective", true), objective: interaction.options.getString("objective", true), possessiveDeterminer: interaction.options.getString( "possessive-determiner", true, ), possessive: interaction.options.getString("possessive-pronoun", true), reflexive: interaction.options.getString("reflexive", true), }; await db .insert(moderators) .values({ user_id: id, ...pronounData, }) .onConflictDoUpdate({ target: moderators.user_id, set: pronounData, }); await interaction.reply({ content: "Pronouns updated.", flags: ["Ephemeral"], }); } export default { data: command, execute, };