Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -2681,23 +2681,33 @@ const pollNeededCount = new Map();
|
|
| 2681 |
// Handle reaction removal to decrease count
|
| 2682 |
client.on('messageReactionRemove', async (reaction, user) => {
|
| 2683 |
if (user.bot) return;
|
| 2684 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2685 |
|
| 2686 |
-
|
| 2687 |
-
|
| 2688 |
-
|
| 2689 |
|
| 2690 |
-
|
| 2691 |
-
|
| 2692 |
-
|
|
|
|
|
|
|
|
|
|
| 2693 |
|
| 2694 |
-
|
| 2695 |
-
|
| 2696 |
|
| 2697 |
-
|
| 2698 |
-
|
| 2699 |
-
|
|
|
|
| 2700 |
}
|
|
|
|
|
|
|
| 2701 |
}
|
| 2702 |
});
|
| 2703 |
|
|
|
|
| 2681 |
// Handle reaction removal to decrease count
|
| 2682 |
client.on('messageReactionRemove', async (reaction, user) => {
|
| 2683 |
if (user.bot) return;
|
| 2684 |
+
|
| 2685 |
+
try {
|
| 2686 |
+
// Handle partials for both reaction and message to ensure content is available
|
| 2687 |
+
if (reaction.partial) await reaction.fetch();
|
| 2688 |
+
if (reaction.message.partial) await reaction.message.fetch();
|
| 2689 |
|
| 2690 |
+
if (reaction.emoji.name === '🟩') {
|
| 2691 |
+
const guildId = reaction.message.guildId;
|
| 2692 |
+
const activePollId = storage.data.active_polls[guildId];
|
| 2693 |
|
| 2694 |
+
if (reaction.message.id === activePollId) {
|
| 2695 |
+
const content = reaction.message.content || "";
|
| 2696 |
+
|
| 2697 |
+
// Safety check: Don't edit if it's a league match or NOT a friendly poll
|
| 2698 |
+
if (content.includes('LEAGUE MATCH')) return;
|
| 2699 |
+
if (!content.includes('FRIENDLY')) return;
|
| 2700 |
|
| 2701 |
+
const count = reaction.count - (reaction.me ? 1 : 0);
|
| 2702 |
+
const needed = pollNeededCount.get(guildId) || 6;
|
| 2703 |
|
| 2704 |
+
// Update the message with current count
|
| 2705 |
+
const baseText = getFriendlyText(guildId, needed);
|
| 2706 |
+
await reaction.message.edit({ content: baseText + `\n\n${count}/${needed} players joined. Waiting for more...` });
|
| 2707 |
+
}
|
| 2708 |
}
|
| 2709 |
+
} catch (err) {
|
| 2710 |
+
console.error("[REACTION-REMOVE] Error handling removal:", err);
|
| 2711 |
}
|
| 2712 |
});
|
| 2713 |
|