Son aktivite 1 month ago

nuno bu gisti düzenledi 1 month ago. Düzenlemeye git

1 file changed, 30 insertions

lock.ts(dosya oluşturuldu)

@@ -0,0 +1,30 @@
1 + import { ChatInputCommandInteraction, TextChannel } from "discord.js";
2 + import { cfg } from "@systems/config";
3 + import { polls, lockPoll, updatePollMessage } from "@systems/poll";
4 + import { replyAndDelete } from "@utils";
5 +
6 + export async function handleLock(interaction: ChatInputCommandInteraction): Promise<void> {
7 + const oneTimeMsg = interaction.options.getString("message") ?? undefined;
8 + const simulateClose = interaction.options.getBoolean("simulate_close") ?? false;
9 + const slot = getActiveSlot();
10 + if (slot === undefined) return void replyAndDelete(interaction, "❌ No active poll found.");
11 +
12 + // Use lockPoll() so lockedYesKeys gets snapshotted — same path as the cron
13 + lockPoll(slot);
14 +
15 + const channel = await interaction.client.channels.fetch(cfg("pollChannelId")) as TextChannel;
16 +
17 + if (simulateClose) {
18 + // Simulate TG end: show Submit Score button (same path as onPollClose cron)
19 + await updatePollMessage(channel, slot, oneTimeMsg, true);
20 + return void replyAndDelete(interaction, "🔒 Poll locked + 📊 Submit Score button shown (simulate close).");
21 + }
22 +
23 + // Normal lock: voting closes, no submit button yet
24 + await updatePollMessage(channel, slot, oneTimeMsg);
25 + return void replyAndDelete(interaction, "🔒 Poll locked.");
26 + }
27 +
28 + function getActiveSlot(): number | undefined {
29 + return [...polls.keys()][0];
30 + }
Daha yeni Daha eski