Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -456,10 +456,18 @@ client.on('messageCreate', async (message) => {
|
|
| 456 |
pingType = mentionArg;
|
| 457 |
guildFriendlyPingType.set(message.guildId, pingType);
|
| 458 |
saveLineup();
|
|
|
|
| 459 |
needed = parseInt(args[1]) || 6;
|
| 460 |
} else if (parseInt(mentionArg)) {
|
| 461 |
needed = parseInt(mentionArg);
|
| 462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
} else {
|
| 464 |
pingType = guildFriendlyPingType.get(message.guildId) || 'everyone';
|
| 465 |
}
|
|
@@ -493,10 +501,12 @@ client.on('messageCreate', async (message) => {
|
|
| 493 |
joined.add(user.id);
|
| 494 |
msg.edit({ content: content + `\n\n${joined.size}/${needed} players joined. Waiting for more...` });
|
| 495 |
}
|
| 496 |
-
if (joined.size >= needed)
|
|
|
|
|
|
|
| 497 |
});
|
| 498 |
collector.on('end', async (col, reason) => {
|
| 499 |
-
if (
|
| 500 |
// Clear lineup before showing
|
| 501 |
const lineup = getGuildLineup(message.guildId);
|
| 502 |
lineup.clear();
|
|
@@ -1849,41 +1859,6 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1849 |
// Store needed count for each active poll
|
| 1850 |
const pollNeededCount = new Map();
|
| 1851 |
|
| 1852 |
-
// Global Reaction Handler (Triggers Lineup)
|
| 1853 |
-
client.on('messageReactionAdd', async (reaction, user) => {
|
| 1854 |
-
if (user.bot) return;
|
| 1855 |
-
if (reaction.partial) await reaction.fetch();
|
| 1856 |
-
|
| 1857 |
-
if (reaction.emoji.name === '🟩') {
|
| 1858 |
-
const guildId = reaction.message.guildId;
|
| 1859 |
-
const activePollId = storage.data.active_polls[guildId];
|
| 1860 |
-
|
| 1861 |
-
if (reaction.message.id === activePollId) {
|
| 1862 |
-
const needed = pollNeededCount.get(guildId) || 6;
|
| 1863 |
-
const count = reaction.count - (reaction.me ? 1 : 0);
|
| 1864 |
-
|
| 1865 |
-
if (count >= needed) {
|
| 1866 |
-
const embed = UI.createEmbed(`${UI.icons.success} Friendly Ready!`, `We have **${count}** players! Starting lineup board...`, UI.colors.success);
|
| 1867 |
-
await reaction.message.channel.send({ embeds: [embed] });
|
| 1868 |
-
|
| 1869 |
-
// Clear lineup before showing
|
| 1870 |
-
const lineup = getGuildLineup(guildId);
|
| 1871 |
-
lineup.clear();
|
| 1872 |
-
saveLineup();
|
| 1873 |
-
|
| 1874 |
-
// Show interactive lineup board (new message, not editing old one)
|
| 1875 |
-
const boardMsg = await reaction.message.channel.send(createLineupView(guildId));
|
| 1876 |
-
activeLineupMessages.set(guildId, { channelId: reaction.message.channelId, messageId: boardMsg.id });
|
| 1877 |
-
addToCleanupQueue(guildId, reaction.message.channelId, boardMsg.id, 'lineup');
|
| 1878 |
-
|
| 1879 |
-
delete storage.data.active_polls[guildId];
|
| 1880 |
-
pollNeededCount.delete(guildId);
|
| 1881 |
-
storage.save('active_polls');
|
| 1882 |
-
}
|
| 1883 |
-
}
|
| 1884 |
-
}
|
| 1885 |
-
});
|
| 1886 |
-
|
| 1887 |
// Handle reaction removal to decrease count
|
| 1888 |
client.on('messageReactionRemove', async (reaction, user) => {
|
| 1889 |
if (user.bot) return;
|
|
|
|
| 456 |
pingType = mentionArg;
|
| 457 |
guildFriendlyPingType.set(message.guildId, pingType);
|
| 458 |
saveLineup();
|
| 459 |
+
// Check if there's a number in args[1]
|
| 460 |
needed = parseInt(args[1]) || 6;
|
| 461 |
} else if (parseInt(mentionArg)) {
|
| 462 |
needed = parseInt(mentionArg);
|
| 463 |
+
// Check if next arg is 'here' or 'everyone'
|
| 464 |
+
if (args[1] === 'here' || args[1] === 'everyone') {
|
| 465 |
+
pingType = args[1];
|
| 466 |
+
guildFriendlyPingType.set(message.guildId, pingType);
|
| 467 |
+
saveLineup();
|
| 468 |
+
} else {
|
| 469 |
+
pingType = guildFriendlyPingType.get(message.guildId) || 'everyone';
|
| 470 |
+
}
|
| 471 |
} else {
|
| 472 |
pingType = guildFriendlyPingType.get(message.guildId) || 'everyone';
|
| 473 |
}
|
|
|
|
| 501 |
joined.add(user.id);
|
| 502 |
msg.edit({ content: content + `\n\n${joined.size}/${needed} players joined. Waiting for more...` });
|
| 503 |
}
|
| 504 |
+
if (joined.size >= needed) {
|
| 505 |
+
collector.stop('ready');
|
| 506 |
+
}
|
| 507 |
});
|
| 508 |
collector.on('end', async (col, reason) => {
|
| 509 |
+
if (reason === 'ready') {
|
| 510 |
// Clear lineup before showing
|
| 511 |
const lineup = getGuildLineup(message.guildId);
|
| 512 |
lineup.clear();
|
|
|
|
| 1859 |
// Store needed count for each active poll
|
| 1860 |
const pollNeededCount = new Map();
|
| 1861 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1862 |
// Handle reaction removal to decrease count
|
| 1863 |
client.on('messageReactionRemove', async (reaction, user) => {
|
| 1864 |
if (user.bot) return;
|