Brozy123 commited on
Commit
ea0cad5
·
verified ·
1 Parent(s): c823ceb

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +31 -23
index.js CHANGED
@@ -2150,33 +2150,41 @@ lineupBoard.clear();
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
- // Defer only after permission checks to allow ephemeral errors
2163
- await interaction.deferReply().catch(() => { });
2164
 
2165
- try {
2166
- const formKey = guildSelectedFormation.get(lineupGuildId) || 'default';
2167
- const formation = formKey === `custom_${lineupGuildId}` ? guildCustomFormations.get(lineupGuildId) : FORMATIONS[formKey];
2168
- const formDisplayName = formKey === `custom_${lineupGuildId}` ? (guildCustomFormationNames.get(lineupGuildId) || "Custom") : formKey;
2169
 
2170
- const attachment = await createLineupAttachment(lineupBoard, formDisplayName, formation || FORMATIONS["default"], client);
2171
- const embed = UI.createEmbed(`⚽ Final Lineup — ${formDisplayName}`, "Here is the visual representation of the starting lineup.");
2172
- embed.setImage('attachment://lineup.png');
2173
- await interaction.editReply({ embeds: [embed], files: [attachment] });
2174
- } catch (err) {
2175
- console.error("Failed to generate lineup image:", err);
2176
- await interaction.editReply({ content: "❌ Failed to generate lineup image. Please try again." }).catch(() => { });
2177
- }
2178
- return;
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_')) {