Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -2519,89 +2519,190 @@ function getFriendlyText(guildId, needed) {
|
|
| 2519 |
}
|
| 2520 |
|
| 2521 |
function createLineupView(guildId) {
|
| 2522 |
-
|
| 2523 |
-
|
| 2524 |
-
|
| 2525 |
-
|
| 2526 |
-
|
| 2527 |
-
|
| 2528 |
-
|
| 2529 |
-
|
| 2530 |
-
|
| 2531 |
-
|
| 2532 |
-
|
| 2533 |
-
|
| 2534 |
-
|
| 2535 |
-
|
| 2536 |
-
|
| 2537 |
-
|
| 2538 |
-
|
| 2539 |
-
|
| 2540 |
-
|
| 2541 |
-
|
| 2542 |
-
|
| 2543 |
-
}
|
| 2544 |
}
|
|
|
|
| 2545 |
|
| 2546 |
-
|
| 2547 |
-
|
| 2548 |
-
|
| 2549 |
-
|
| 2550 |
-
|
| 2551 |
-
|
| 2552 |
-
|
| 2553 |
-
|
| 2554 |
-
|
| 2555 |
-
|
| 2556 |
-
|
| 2557 |
-
|
| 2558 |
-
|
| 2559 |
-
|
| 2560 |
-
|
| 2561 |
-
|
| 2562 |
-
|
| 2563 |
-
|
| 2564 |
-
|
| 2565 |
-
|
| 2566 |
-
|
| 2567 |
-
|
| 2568 |
-
|
| 2569 |
-
|
| 2570 |
-
|
| 2571 |
-
|
| 2572 |
-
|
| 2573 |
-
|
| 2574 |
-
|
| 2575 |
-
|
| 2576 |
-
|
| 2577 |
-
|
| 2578 |
-
|
| 2579 |
-
|
| 2580 |
-
|
| 2581 |
-
|
| 2582 |
-
|
| 2583 |
-
|
| 2584 |
-
|
| 2585 |
-
|
| 2586 |
-
|
| 2587 |
-
|
| 2588 |
-
|
| 2589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2590 |
|
| 2591 |
-
|
| 2592 |
-
|
| 2593 |
-
|
| 2594 |
-
|
| 2595 |
-
|
| 2596 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2597 |
|
| 2598 |
-
|
| 2599 |
-
|
| 2600 |
-
|
| 2601 |
-
|
| 2602 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2603 |
|
| 2604 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2605 |
}
|
| 2606 |
|
| 2607 |
function createManagerEditor(guildId, client) {
|
|
|
|
| 2519 |
}
|
| 2520 |
|
| 2521 |
function createLineupView(guildId) {
|
| 2522 |
+
const lineup = getGuildLineup(guildId);
|
| 2523 |
+
const formKey = guildSelectedFormation.get(guildId) || 'default';
|
| 2524 |
+
const formation = formKey === `custom_${guildId}` ? guildCustomFormations.get(guildId) : FORMATIONS[formKey];
|
| 2525 |
+
const formDisplayName = formKey === `custom_${guildId}` ? (guildCustomFormationNames.get(guildId) || "Custom") : formKey;
|
| 2526 |
+
|
| 2527 |
+
if (!formation) return { content: "❌ Error: Formation not found." };
|
| 2528 |
+
|
| 2529 |
+
let text = "";
|
| 2530 |
+
for (const [posKey, posLabel] of formation) {
|
| 2531 |
+
const players = lineup.get(posKey) || [];
|
| 2532 |
+
const resolvedLabel = resolveEmojis(posLabel, guildId);
|
| 2533 |
+
if (players.length > 0) {
|
| 2534 |
+
const starter = players[0];
|
| 2535 |
+
const subs = players.slice(1);
|
| 2536 |
+
let line = `🟩 **${resolvedLabel}** ➔ <@${starter}>`;
|
| 2537 |
+
if (subs.length > 0) {
|
| 2538 |
+
line += ` (Substitute: ` + subs.map(p => `<@${p}>`).join(', ') + `)`;
|
| 2539 |
+
}
|
| 2540 |
+
text += line + "\n\n";
|
| 2541 |
+
} else {
|
| 2542 |
+
text += `⬛ **${resolvedLabel}** ➔ *Open*\n\n`;
|
|
|
|
| 2543 |
}
|
| 2544 |
+
}
|
| 2545 |
|
| 2546 |
+
const embed = UI.createEmbed(`⚽ MATCH LINEUP — ${resolveEmojis(formDisplayName, guildId)}`, text, UI.colors.primary);
|
| 2547 |
+
embed.setFooter({ text: "Click a position below to join/leave! Use the dropdown to change formation." });
|
| 2548 |
+
|
| 2549 |
+
const rows = [];
|
| 2550 |
+
|
| 2551 |
+
// In the active board, we condense the 3 dropdowns into 2 rows to fit within Discord's 5-row limit
|
| 2552 |
+
// Condense UI: Only the Category Selection is on the public board
|
| 2553 |
+
const categoryRow = new ActionRowBuilder().addComponents(
|
| 2554 |
+
new StringSelectMenuBuilder()
|
| 2555 |
+
.setCustomId('formation_category_select')
|
| 2556 |
+
.setPlaceholder('📂 Change Formation Size (7v7, 11v11, others...)')
|
| 2557 |
+
.addOptions([
|
| 2558 |
+
{ label: '⚽ 7v7 Formations', value: 'cat_7v7', emoji: '⚽' },
|
| 2559 |
+
{ label: '🏆 11v11 Formations', value: 'cat_11v11', emoji: '🏆' },
|
| 2560 |
+
{ label: '🎮 Other Sizes (6v6, 8v8, 9v9, 10v10)', value: 'cat_other', emoji: '🎮' }
|
| 2561 |
+
])
|
| 2562 |
+
);
|
| 2563 |
+
rows.push(categoryRow);
|
| 2564 |
+
|
| 2565 |
+
// Position Buttons
|
| 2566 |
+
let currentRow = new ActionRowBuilder();
|
| 2567 |
+
let currentPosCount = 0;
|
| 2568 |
+
|
| 2569 |
+
formation.forEach(([posKey, posLabel]) => {
|
| 2570 |
+
if (currentPosCount === 5) { // 5 buttons per row for better fit on mobile
|
| 2571 |
+
rows.push(currentRow);
|
| 2572 |
+
currentRow = new ActionRowBuilder();
|
| 2573 |
+
currentPosCount = 0;
|
| 2574 |
+
}
|
| 2575 |
+
const players = lineup.get(posKey) || [];
|
| 2576 |
+
const btnLabel = posLabel;
|
| 2577 |
+
|
| 2578 |
+
const btn = new ButtonBuilder()
|
| 2579 |
+
.setCustomId(`join_${posKey}`)
|
| 2580 |
+
.setLabel(players.length > 0 ? `${btnLabel}: ✅` : btnLabel)
|
| 2581 |
+
.setStyle(players.length > 0 ? ButtonStyle.Secondary : ButtonStyle.Primary);
|
| 2582 |
+
|
| 2583 |
+
if (players.length > 0) {
|
| 2584 |
+
btn.setEmoji("✅");
|
| 2585 |
+
}
|
| 2586 |
+
currentRow.addComponents(btn);
|
| 2587 |
+
currentPosCount++;
|
| 2588 |
+
});
|
| 2589 |
+
if (currentPosCount > 0) rows.push(currentRow);
|
| 2590 |
+
|
| 2591 |
+
// Clear, Custom and Done Buttons
|
| 2592 |
+
rows.push(new ActionRowBuilder().addComponents(
|
| 2593 |
+
new ButtonBuilder().setCustomId('lineup_done').setLabel('Show Final Image').setStyle(ButtonStyle.Success).setEmoji("🖼️"),
|
| 2594 |
+
new ButtonBuilder().setCustomId('open_custom_lineup_modal').setLabel('Custom / Other Sizes').setStyle(ButtonStyle.Primary).setEmoji("🛠️"),
|
| 2595 |
+
new ButtonBuilder().setCustomId('lineup_clear').setLabel('Clear Board').setStyle(ButtonStyle.Danger)
|
| 2596 |
+
));
|
| 2597 |
+
|
| 2598 |
+
const pingType = guildPingType.get(guildId) || 'everyone';
|
| 2599 |
+
const pingMention = pingType === 'here' ? '@here' : '@everyone';
|
| 2600 |
+
// Always use a safe allowedMentions parse value
|
| 2601 |
+
const mentionParse = ['everyone'];
|
| 2602 |
+
const content = `${pingMention}\n**Lineup Session Active!**`;
|
| 2603 |
+
|
| 2604 |
+
return { content, embeds: [embed], components: rows, allowedMentions: { parse: mentionParse } };
|
| 2605 |
+
}
|
| 2606 |
|
| 2607 |
+
function createScrimLineupView(guildId) {
|
| 2608 |
+
const lineup = getGuildLineup(guildId);
|
| 2609 |
+
const formKey = guildSelectedFormation.get(guildId) || 'default';
|
| 2610 |
+
const formation = formKey === `custom_${guildId}` ? guildCustomFormations.get(guildId) : FORMATIONS[formKey];
|
| 2611 |
+
const formDisplayName = formKey === `custom_${guildId}` ? (guildCustomFormationNames.get(guildId) || "Custom") : formKey;
|
| 2612 |
+
|
| 2613 |
+
if (!formation) return { content: "❌ Error: Formation not found." };
|
| 2614 |
+
|
| 2615 |
+
let text = "";
|
| 2616 |
+
for (const [posKey, posLabel] of formation) {
|
| 2617 |
+
const players = lineup.get(posKey) || [];
|
| 2618 |
+
const resolvedLabel = resolveEmojis(posLabel, guildId);
|
| 2619 |
+
if (players.length > 0) {
|
| 2620 |
+
const starter = players[0];
|
| 2621 |
+
const subs = players.slice(1);
|
| 2622 |
+
let line = `🟩 **${resolvedLabel}** ➔ <@${starter}>`;
|
| 2623 |
+
if (subs.length > 0) {
|
| 2624 |
+
line += ` (Substitute: ` + subs.map(p => `<@${p}>`).join(', ') + `)`;
|
| 2625 |
+
}
|
| 2626 |
+
text += line + "\n\n";
|
| 2627 |
+
} else {
|
| 2628 |
+
text += `⬛ **${resolvedLabel}** ➔ *Open*\n\n`;
|
| 2629 |
+
}
|
| 2630 |
+
}
|
| 2631 |
|
| 2632 |
+
let textRotated = "";
|
| 2633 |
+
const reversedFormation = [...formation].reverse();
|
| 2634 |
+
for (const [posKey, posLabel] of reversedFormation) {
|
| 2635 |
+
const players = lineup.get(posKey) || [];
|
| 2636 |
+
const resolvedLabel = resolveEmojis(posLabel, guildId);
|
| 2637 |
+
if (players.length > 0) {
|
| 2638 |
+
const starter = players[0];
|
| 2639 |
+
const subs = players.slice(1);
|
| 2640 |
+
let line = `🟩 **${resolvedLabel}** ➔ <@${starter}>`;
|
| 2641 |
+
if (subs.length > 0) {
|
| 2642 |
+
line += ` (Substitute: ` + subs.map(p => `<@${p}>`).join(', ') + `)`;
|
| 2643 |
+
}
|
| 2644 |
+
text_rotated += line + "\n\n";
|
| 2645 |
+
} else {
|
| 2646 |
+
text_rotated += `⬛ **${resolvedLabel}** ➔ *Open*\n\n`;
|
| 2647 |
+
}
|
| 2648 |
+
}
|
| 2649 |
|
| 2650 |
+
const embed = UI.createEmbed(`⚽ SCRIMMAGE LINEUP — ${resolveEmojis(formDisplayName, guildId)}`, text, UI.colors.primary);
|
| 2651 |
+
embed.setFooter({ text: "Left: Team A | Right: Team B (Rotated) | Click positions to join/leave" });
|
| 2652 |
+
|
| 2653 |
+
const embedRotated = UI.createEmbed(`🔄 TEAM B (ROTATED)`, text_rotated, UI.colors.success);
|
| 2654 |
+
|
| 2655 |
+
const rows = [];
|
| 2656 |
+
|
| 2657 |
+
const categoryRow = new ActionRowBuilder().addComponents(
|
| 2658 |
+
new StringSelectMenuBuilder()
|
| 2659 |
+
.setCustomId('formation_category_select')
|
| 2660 |
+
.setPlaceholder('📂 Change Formation Size (7v7, 11v11, others...)')
|
| 2661 |
+
.addOptions([
|
| 2662 |
+
{ label: '⚽ 7v7 Formations', value: 'cat_7v7', emoji: '⚽' },
|
| 2663 |
+
{ label: '🏆 11v11 Formations', value: 'cat_11v11', emoji: '🏆' },
|
| 2664 |
+
{ label: '🎮 Other Sizes (6v6, 8v8, 9v9, 10v10)', value: 'cat_other', emoji: '🎮' }
|
| 2665 |
+
])
|
| 2666 |
+
);
|
| 2667 |
+
rows.push(categoryRow);
|
| 2668 |
+
|
| 2669 |
+
let currentRow = new ActionRowBuilder();
|
| 2670 |
+
let currentPosCount = 0;
|
| 2671 |
+
|
| 2672 |
+
formation.forEach(([posKey, posLabel]) => {
|
| 2673 |
+
if (currentPosCount === 5) {
|
| 2674 |
+
rows.push(currentRow);
|
| 2675 |
+
currentRow = new ActionRowBuilder();
|
| 2676 |
+
currentPosCount = 0;
|
| 2677 |
+
}
|
| 2678 |
+
const players = lineup.get(posKey) || [];
|
| 2679 |
+
const btnLabel = posLabel;
|
| 2680 |
+
|
| 2681 |
+
const btn = new ButtonBuilder()
|
| 2682 |
+
.setCustomId(`join_${posKey}`)
|
| 2683 |
+
.setLabel(players.length > 0 ? `${btnLabel}: ✅` : btnLabel)
|
| 2684 |
+
.setStyle(players.length > 0 ? ButtonStyle.Secondary : ButtonStyle.Primary);
|
| 2685 |
+
|
| 2686 |
+
if (players.length > 0) {
|
| 2687 |
+
btn.setEmoji("✅");
|
| 2688 |
+
}
|
| 2689 |
+
currentRow.addComponents(btn);
|
| 2690 |
+
currentPosCount++;
|
| 2691 |
+
});
|
| 2692 |
+
if (currentPosCount > 0) rows.push(currentRow);
|
| 2693 |
+
|
| 2694 |
+
rows.push(new ActionRowBuilder().addComponents(
|
| 2695 |
+
new ButtonBuilder().setCustomId('lineup_done').setLabel('Show Final Image').setStyle(ButtonStyle.Success).setEmoji("🖼️"),
|
| 2696 |
+
new ButtonBuilder().setCustomId('open_custom_lineup_modal').setLabel('Custom / Other Sizes').setStyle(ButtonStyle.Primary).setEmoji("🛠️"),
|
| 2697 |
+
new ButtonBuilder().setCustomId('lineup_clear').setLabel('Clear Board').setStyle(ButtonStyle.Danger)
|
| 2698 |
+
));
|
| 2699 |
+
|
| 2700 |
+
const pingType = guildPingType.get(guildId) || 'everyone';
|
| 2701 |
+
const pingMention = pingType === 'here' ? '@here' : '@everyone';
|
| 2702 |
+
const mentionParse = ['everyone'];
|
| 2703 |
+
const content = `${pingMention}\n**🔥 SCRIMMAGE LINEUP SESSION ACTIVE!**\n*Two teams facing each other!*`;
|
| 2704 |
+
|
| 2705 |
+
return { content, embeds: [embed, embedRotated], components: rows, allowedMentions: { parse: mentionParse } };
|
| 2706 |
}
|
| 2707 |
|
| 2708 |
function createManagerEditor(guildId, client) {
|