Spaces:
Runtime error
Runtime error
Update index.js
Browse files425 unmodified lines4264274284294304314324334344352148 unmodified lines258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655274 unmodified lines2930293129322933425 unmodified lines// --- 3. EVENT HANDLERS ---client.on('messageCreate', async (message) => {if (message.channel.type === 1) { // DM channelif (message.author.bot) return;return;}collector.on('end', async (col, reason) => {if (reason === 'ready') {const lineup = getGuildLineup(message.guildId);2148 unmodified linesconst content = `${pingMention}\n**🔥 SCRIMMAGE LINEUP SESSION ACTIVE!**\n*Two teams facing each other!*`;return { content, embeds: [embedA, embedB], components: rows, allowedMentions: { parse: mentionParse } };}text += line + "\n\n";} else {text += `⬛ **${resolvedLabel}** ➔ *Open*\n\n`;}}const embed = UI.createEmbed(`⚽ MATCH LINEUP — ${resolveEmojis(formDisplayName, guildId)}`, text, UI.colors.primary);embed.setFooter({ text: "Click a position below to join/leave! Use the dropdown to change formation." });const rows = [];// In the active board, we condense the 3 dropdowns into 2 rows to fit within Discord's 5-row limit// Condense UI: Only the Category Selection is on the public boardconst categoryRow = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId('formation_category_select').setPlaceholder('📂 Change Formation Size (7v7, 11v11, others...)').addOptions([{ label: '⚽ 7v7 Formations', value: 'cat_7v7', emoji: '⚽' },{ label: '🏆 11v11 Formations', value: 'cat_11v11', emoji: '🏆' },{ label: '🎮 Other Sizes (6v6, 8v8, 9v9, 10v10)', value: 'cat_other', emoji: '🎮' }]));rows.push(categoryRow);// Position Buttonslet currentRow = new ActionRowBuilder();let currentPosCount = 0;formation.forEach(([posKey, posLabel]) => {if (currentPosCount === 5) { // 5 buttons per row for better fit on mobilerows.push(currentRow);currentRow = new ActionRowBuilder();currentPosCount = 0;}const players = lineup.get(posKey) || [];const btnLabel = posLabel;const btn = new ButtonBuilder().setCustomId(`join_${posKey}`).setLabel(players.length > 0 ? `${btnLabel}: ✅` : btnLabel).setStyle(players.length > 0 ? ButtonStyle.Secondary : ButtonStyle.Primary);if (players.length > 0) {btn.setEmoji("✅");}currentRow.addComponents(btn);currentPosCount++;});if (currentPosCount > 0) rows.push(currentRow);// Clear, Custom and Done Buttonsrows.push(new ActionRowBuilder().addComponents(new ButtonBuilder().setCustomId('lineup_done').setLabel('Show Final Image').setStyle(ButtonStyle.Success).setEmoji("🖼️"),new ButtonBuilder().setCustomId('open_custom_lineup_modal').setLabel('Custom / Other Sizes').setStyle(ButtonStyle.Primary).setEmoji("🛠️"),new ButtonBuilder().setCustomId('lineup_clear').setLabel('Clear Board').setStyle(ButtonStyle.Danger)));const pingType = guildPingType.get(guildId) || 'everyone';const pingMention = pingType === 'here' ? '@here' : '@everyone';// Always use a safe allowedMentions parse valueconst mentionParse = ['everyone'];const content = `${pingMention}\n**Lineup Session Active!**`;return { content, embeds: [embed], components: rows, allowedMentions: { parse: mentionParse } };}function createManagerEditor(guildId, client) {const lineup = getGuildLineup(guildId);274 unmodified linesinitialize().catch(err => {console.error(">>> [BOOT] CRITICAL INITIALIZATION ERROR:", err);process.exit(1);});425 unmodified lines4264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814822148 unmodified lines26312632263326342635263626372638274 unmodified lines29132914291529162917425 unmodified lines// --- 3. EVENT HANDLERS ---client.on('messageCreate', async (message) => {if (message.author.bot) return;const prefix = storage.getPrefix(message.guildId);if (!prefix || !message.content.startsWith(prefix)) return;const args = message.content.slice(prefix.length).trim().split(/ +/);const commandName = args.shift().toLowerCase();if (message.channel.type === 1) { // DM channelreturn;}if (commandName === 'friendly') {if (!roleStorage.isWhitelisted(message.guildId, message.member)) return sendNoPermission(message);const mentionArg = args[0] ? args[0].toLowerCase().replace('@', '') : null;let needed = 6;let pingType = 'everyone';if (mentionArg === 'here' || mentionArg === 'everyone') {pingType = mentionArg;needed = parseInt(args[1]) || 6;} else if (parseInt(mentionArg)) {needed = parseInt(mentionArg);if (args[1] === 'here' || args[1] === 'everyone') {pingType = args[1];}}guildFriendlyPingType.set(message.guildId, pingType);saveLineup();pollNeededCount.set(message.guildId, needed);let content = pingType === 'here' ? getFriendlyText(message.guildId, needed).replace('@everyone', '@here') : getFriendlyText(message.guildId, needed);const msg = await message.channel.send({ content, allowedMentions: { parse: ['everyone'] } });await msg.react('🟩').catch(() => {});await msg.react('🟥').catch(() => {});storage.data.active_polls[message.guildId] = msg.id;storage.save('active_polls');const joined = new Set();const filter = (reaction, user) => (reaction.emoji.name === '🟩' || reaction.emoji.name === "I'm In") && !user.bot;const collector = msg.createReactionCollector({ filter, time: 600000 });collector.on('collect', (reaction, user) => {if (!joined.has(user.id)) {joined.add(user.id);msg.edit({ content: content + `\n\n${joined.size}/${needed} players joined. Waiting for more...` });}if (joined.size >= needed) collector.stop('ready');});collector.on('end', async (col, reason) => {if (reason === 'ready') {const lineup = getGuildLineup(message.guildId);2148 unmodified linesconst content = `${pingMention}\n**🔥 SCRIMMAGE LINEUP SESSION ACTIVE!**\n*Two teams facing each other!*`;return { content, embeds: [embedA, embedB], components: rows, allowedMentions: { parse: mentionParse } };}function createManagerEditor(guildId, client) {const lineup = getGuildLineup(guildId);274 unmodified linesinitialize().catch(err => {console.error(">>> [BOOT] CRITICAL INITIALIZATION ERROR:", err);process.exit(1);});
index.js+50-66