import { db, userPreferences } from "@/database"; import { type ChatInputCommandInteraction, type Client, SlashCommandBuilder } from "discord.js"; import { eq } from "drizzle-orm"; const commandData = new SlashCommandBuilder() .setName("uwuify-toggle") .setDescription("toggle automatic uwuification of your messages"); async function execute(_client: Client, interaction: ChatInputCommandInteraction) { const userId = interaction.user.id; const existing = db .select() .from(userPreferences) .where(eq(userPreferences.userId, userId)) .get(); const isCurrentlyEnabled = existing?.uwuifyMessages === "enabled"; const newState = isCurrentlyEnabled ? "disabled" : "enabled"; if (existing) { await db .update(userPreferences) .set({ uwuifyMessages: newState }) .where(eq(userPreferences.userId, userId)); } else { await db.insert(userPreferences).values({ userId, uwuifyMessages: newState, }); } const status = newState === "enabled" ? "enabled" : "disabled"; await interaction.reply({ content: `✅ uwuification ${status}!`, flags: ["Ephemeral"], }); } export default { data: commandData, execute, };