Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -210,8 +210,15 @@ client.on('messageCreate', async (message) => {
|
|
| 210 |
|
| 211 |
if (commandName === 'lineup') {
|
| 212 |
if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
}
|
| 216 |
|
| 217 |
if (commandName === 'top') {
|
|
@@ -559,8 +566,15 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 559 |
|
| 560 |
if (interaction.commandName === 'lineup') {
|
| 561 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", ephemeral: true });
|
| 562 |
-
|
| 563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
}
|
| 565 |
|
| 566 |
if (interaction.commandName === 'clear') {
|
|
@@ -729,17 +743,19 @@ function createLineupView(guildId) {
|
|
| 729 |
const formKey = guildSelectedFormation.get(guildId) || 'default';
|
| 730 |
const formation = FORMATIONS[formKey];
|
| 731 |
|
| 732 |
-
let text =
|
| 733 |
for (const [posKey, posLabel] of formation) {
|
| 734 |
const players = lineup.get(posKey) || [];
|
| 735 |
if (players.length > 0) {
|
| 736 |
-
text += `${posLabel}
|
| 737 |
} else {
|
| 738 |
-
text += `${posLabel}`;
|
| 739 |
}
|
| 740 |
-
text += "\n";
|
| 741 |
}
|
| 742 |
|
|
|
|
|
|
|
|
|
|
| 743 |
const rows = [];
|
| 744 |
|
| 745 |
// Formation Dropdown
|
|
@@ -747,7 +763,7 @@ function createLineupView(guildId) {
|
|
| 747 |
rows.push(new ActionRowBuilder().addComponents(
|
| 748 |
new StringSelectMenuBuilder()
|
| 749 |
.setCustomId('formation_select')
|
| 750 |
-
.setPlaceholder(
|
| 751 |
.addOptions(formOptions)
|
| 752 |
));
|
| 753 |
|
|
@@ -782,7 +798,7 @@ function createLineupView(guildId) {
|
|
| 782 |
new ButtonBuilder().setCustomId('lineup_clear').setLabel('Clear Board').setStyle(ButtonStyle.Danger)
|
| 783 |
));
|
| 784 |
|
| 785 |
-
return { content:
|
| 786 |
}
|
| 787 |
|
| 788 |
// --- 5. MANAGER GUI LOGIC ---
|
|
@@ -834,6 +850,15 @@ function createManagerEditor(guildId, client) {
|
|
| 834 |
|
| 835 |
// Interaction Handler for Lineup Components
|
| 836 |
client.on('interactionCreate', async (interaction) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 837 |
if (interaction.isSelectMenu() && interaction.customId === 'formation_select') {
|
| 838 |
if (!storage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission to change formations.", ephemeral: true });
|
| 839 |
const guildId = interaction.guildId;
|
|
|
|
| 210 |
|
| 211 |
if (commandName === 'lineup') {
|
| 212 |
if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
|
| 213 |
+
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 214 |
+
const row = new ActionRowBuilder().addComponents(
|
| 215 |
+
new StringSelectMenuBuilder()
|
| 216 |
+
.setCustomId('formation_select_initial')
|
| 217 |
+
.setPlaceholder('Step 1: Select Formation...')
|
| 218 |
+
.addOptions(formOptions)
|
| 219 |
+
);
|
| 220 |
+
const embed = UI.createEmbed("📋 Initialize Lineup", "Please select a formation to create the lineup board.", UI.colors.primary);
|
| 221 |
+
await message.channel.send({ embeds: [embed], components: [row] });
|
| 222 |
}
|
| 223 |
|
| 224 |
if (commandName === 'top') {
|
|
|
|
| 566 |
|
| 567 |
if (interaction.commandName === 'lineup') {
|
| 568 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", ephemeral: true });
|
| 569 |
+
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 570 |
+
const row = new ActionRowBuilder().addComponents(
|
| 571 |
+
new StringSelectMenuBuilder()
|
| 572 |
+
.setCustomId('formation_select_initial')
|
| 573 |
+
.setPlaceholder('Step 1: Select Formation...')
|
| 574 |
+
.addOptions(formOptions)
|
| 575 |
+
);
|
| 576 |
+
const embed = UI.createEmbed("📋 Initialize Lineup", "Please select a formation to create the lineup board.", UI.colors.primary);
|
| 577 |
+
await interaction.reply({ embeds: [embed], components: [row] });
|
| 578 |
}
|
| 579 |
|
| 580 |
if (interaction.commandName === 'clear') {
|
|
|
|
| 743 |
const formKey = guildSelectedFormation.get(guildId) || 'default';
|
| 744 |
const formation = FORMATIONS[formKey];
|
| 745 |
|
| 746 |
+
let text = "";
|
| 747 |
for (const [posKey, posLabel] of formation) {
|
| 748 |
const players = lineup.get(posKey) || [];
|
| 749 |
if (players.length > 0) {
|
| 750 |
+
text += `🟩 **${posLabel}** ➔ ` + players.map(p => `<@${p}>`).join(', ') + "\n";
|
| 751 |
} else {
|
| 752 |
+
text += `⬛ **${posLabel}** ➔ 🈳 *Open*\n`;
|
| 753 |
}
|
|
|
|
| 754 |
}
|
| 755 |
|
| 756 |
+
const embed = UI.createEmbed(`⚽ MATCH LINEUP — ${formKey}`, text, UI.colors.primary);
|
| 757 |
+
embed.setFooter({ text: "Click a position below to join/leave! Use the dropdown to change formation." });
|
| 758 |
+
|
| 759 |
const rows = [];
|
| 760 |
|
| 761 |
// Formation Dropdown
|
|
|
|
| 763 |
rows.push(new ActionRowBuilder().addComponents(
|
| 764 |
new StringSelectMenuBuilder()
|
| 765 |
.setCustomId('formation_select')
|
| 766 |
+
.setPlaceholder(`Current Formation: ${formKey} (Click to change)`)
|
| 767 |
.addOptions(formOptions)
|
| 768 |
));
|
| 769 |
|
|
|
|
| 798 |
new ButtonBuilder().setCustomId('lineup_clear').setLabel('Clear Board').setStyle(ButtonStyle.Danger)
|
| 799 |
));
|
| 800 |
|
| 801 |
+
return { content: "@everyone\n**Lineup Session Active!**", embeds: [embed], components: rows, allowedMentions: { parse: ['everyone'] } };
|
| 802 |
}
|
| 803 |
|
| 804 |
// --- 5. MANAGER GUI LOGIC ---
|
|
|
|
| 850 |
|
| 851 |
// Interaction Handler for Lineup Components
|
| 852 |
client.on('interactionCreate', async (interaction) => {
|
| 853 |
+
if (interaction.isSelectMenu() && interaction.customId === 'formation_select_initial') {
|
| 854 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission.", ephemeral: true });
|
| 855 |
+
const guildId = interaction.guildId;
|
| 856 |
+
guildSelectedFormation.set(guildId, interaction.values[0]);
|
| 857 |
+
guildLineups.set(guildId, new Map());
|
| 858 |
+
await interaction.update(createLineupView(guildId));
|
| 859 |
+
return;
|
| 860 |
+
}
|
| 861 |
+
|
| 862 |
if (interaction.isSelectMenu() && interaction.customId === 'formation_select') {
|
| 863 |
if (!storage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission to change formations.", ephemeral: true });
|
| 864 |
const guildId = interaction.guildId;
|