import { ChatInputCommandInteraction, TextChannel } from "discord.js"; import { cfg } from "../../systems/config"; import { polls, updatePollMessage } from "../../systems/poll"; import { replyAndDelete } from "../../utils"; export async function handleLock(interaction: ChatInputCommandInteraction): Promise { const oneTimeMsg = interaction.options.getString("message") ?? undefined; const slot = getActiveSlot(); if (!slot) return void replyAndDelete(interaction, "❌ No active poll found."); const state = polls.get(slot)!; state.locked = true; const channel = await interaction.client.channels.fetch(cfg("pollChannelId")) as TextChannel; await updatePollMessage(channel, slot, oneTimeMsg); return void replyAndDelete(interaction, "🔒 Poll locked."); } function getActiveSlot(): number | undefined { return [...polls.keys()][0]; }