Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
|
@@ -2150,33 +2150,41 @@ lineupBoard.clear();
|
|
| 2150 |
}
|
| 2151 |
|
| 2152 |
if (interaction.customId === 'lineup_done') {
|
| 2153 |
-
|
| 2154 |
-
|
| 2155 |
-
|
| 2156 |
|
| 2157 |
-
|
| 2158 |
-
|
| 2159 |
-
|
| 2160 |
-
|
| 2161 |
|
| 2162 |
-
|
| 2163 |
-
await interaction.deferReply().catch(() => { });
|
| 2164 |
|
| 2165 |
-
|
| 2166 |
-
|
| 2167 |
-
|
| 2168 |
-
|
| 2169 |
|
| 2170 |
-
|
| 2171 |
-
|
| 2172 |
-
|
| 2173 |
-
|
| 2174 |
-
|
| 2175 |
-
|
| 2176 |
-
|
| 2177 |
-
|
| 2178 |
-
|
| 2179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2180 |
}
|
| 2181 |
|
| 2182 |
if (interaction.customId && interaction.customId.startsWith('tz_select_')) {
|
|
|
|
| 2150 |
}
|
| 2151 |
|
| 2152 |
if (interaction.customId === 'lineup_done') {
|
| 2153 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) {
|
| 2154 |
+
return sendNoPermission(interaction);
|
| 2155 |
+
}
|
| 2156 |
|
| 2157 |
+
const ownerId = lineupOwners.get(interaction.guildId);
|
| 2158 |
+
if (ownerId && interaction.user.id !== ownerId) {
|
| 2159 |
+
return interaction.reply({ content: `❌ Only <@${ownerId}> can generate the final image!`, flags: [MessageFlags.Ephemeral] });
|
| 2160 |
+
}
|
| 2161 |
|
| 2162 |
+
await interaction.deferReply().catch(() => { });
|
|
|
|
| 2163 |
|
| 2164 |
+
try {
|
| 2165 |
+
const formKey = guildSelectedFormation.get(lineupGuildId) || 'default';
|
| 2166 |
+
const formation = formKey === `custom_${lineupGuildId}` ? guildCustomFormations.get(lineupGuildId) : FORMATIONS[formKey];
|
| 2167 |
+
const formDisplayName = formKey === `custom_${lineupGuildId}` ? (guildCustomFormationNames.get(lineupGuildId) || "Custom") : formKey;
|
| 2168 |
|
| 2169 |
+
const isScrim = guildScrimMode.get(lineupGuildId) === true;
|
| 2170 |
+
|
| 2171 |
+
if (isScrim) {
|
| 2172 |
+
const attachment = await createScrimmageAttachment(lineupBoard, formDisplayName, formation || FORMATIONS["default"], client);
|
| 2173 |
+
const embed = UI.createEmbed(`⚽ SCRIMMAGE — ${formDisplayName}`, "**Team A** (Left) vs **Team B** (Right) - Teams face each other on the pitch.");
|
| 2174 |
+
embed.setImage('attachment://scrimmage.png');
|
| 2175 |
+
await interaction.editReply({ embeds: [embed], files: [attachment] });
|
| 2176 |
+
} else {
|
| 2177 |
+
const attachment = await createLineupAttachment(lineupBoard, formDisplayName, formation || FORMATIONS["default"], client);
|
| 2178 |
+
const embed = UI.createEmbed(`⚽ Final Lineup — ${formDisplayName}`, "Here is the visual representation of the starting lineup.");
|
| 2179 |
+
embed.setImage('attachment://lineup.png');
|
| 2180 |
+
await interaction.editReply({ embeds: [embed], files: [attachment] });
|
| 2181 |
+
}
|
| 2182 |
+
} catch (err) {
|
| 2183 |
+
console.error("Failed to generate lineup image:", err);
|
| 2184 |
+
await interaction.editReply({ content: "❌ Failed to generate lineup image. Please try again." }).catch(() => { });
|
| 2185 |
+
}
|
| 2186 |
+
return;
|
| 2187 |
+
}
|
| 2188 |
}
|
| 2189 |
|
| 2190 |
if (interaction.customId && interaction.customId.startsWith('tz_select_')) {
|