Остання активність 4 weeks ago

nuno ревизій цього gist 4 weeks ago. До ревизії

1 file changed, 36 insertions

gistfile1.txt(файл створено)

@@ -0,0 +1,36 @@
1 + export async function showActiveCharSwitching(interaction: ButtonInteraction): Promise<void> {
2 + const userId = interaction.user.id;
3 + const member = interaction.guild!.members.cache.get(userId)
4 + ?? await interaction.guild!.members.fetch(userId);
5 + const user = await resolveUser(member);
6 +
7 + const impersonating = getImpersonation(userId);
8 + const voteId = impersonating ? `impersonated:${impersonating}` : userId;
9 + const clicks = clickCounts.get(voteId)!;
10 +
11 + const votedYes = interaction.customId === "tg_yes";
12 + const clickCount = votedYes ? clicks.yes : clicks.no;
13 +
14 + const locked = clickCount >= LOCK_AT;
15 +
16 + // Yes vote companion — show active char + switch buttons
17 + if (votedYes && user.userKey && !locked) {
18 + const { char, borrowedFrom } = getEffectiveCharacter(user.userKey);
19 + if (char) {
20 + const starEmoji = process.env.ACTIVE_CHAR_EMOJI || "⭐";
21 + const borrowNote = borrowedFrom ? ` 🔗` : "";
22 + const buttons = buildCharSelectButtons(user.userKey, {
23 + customIdPrefix: `companion_switch:${user.userKey}`,
24 + excludeCharName: char.name,
25 + appendToCustomId: ":yes",
26 + });
27 + if (buttons.length > 0) {
28 + await interaction.followUp({
29 + content: `${starEmoji} ${format.char(char)}${borrowNote}`,
30 + components: buttons,
31 + ephemeral: true,
32 + });
33 + }
34 + }
35 + }
36 + }
Новіше Пізніше