Naposledy aktivní 1 month ago

nuno revidoval tento gist 1 month ago. Přejít na revizi

1 file changed, 21 insertions

lock.ts(vytvořil soubor)

@@ -0,0 +1,21 @@
1 + import { ChatInputCommandInteraction, TextChannel } from "discord.js";
2 + import { cfg } from "../../systems/config";
3 + import { polls, 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 slot = getActiveSlot();
9 + if (!slot) return void replyAndDelete(interaction, "❌ No active poll found.");
10 +
11 + const state = polls.get(slot)!;
12 + state.locked = true;
13 +
14 + const channel = await interaction.client.channels.fetch(cfg("pollChannelId")) as TextChannel;
15 + await updatePollMessage(channel, slot, oneTimeMsg);
16 + return void replyAndDelete(interaction, "🔒 Poll locked.");
17 + }
18 +
19 + function getActiveSlot(): number | undefined {
20 + return [...polls.keys()][0];
21 + }
Novější Starší