Spaces:
Runtime error
Runtime error
Update index.js
Browse files37 unmodified lines383940414243441895 unmodified lines1940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196237 unmodified linesconst guildActiveCategory = new Map(); // Stores the currently selected category in the UI for each guildtry {const { createLineupAttachment } = require('./lineupRenderer');const { createProfileAttachment } = require('./profileRenderer');const { TACTICS, createTacticAttachment } = require('./tacticRenderer');global.createLineupAttachment = createLineupAttachment;1895 unmodified linesreturn interaction.reply({ content: `❌ Only <@${ownerId}> can generate the final image!`, flags: [MessageFlags.Ephemeral] });}// Defer only after permission checks to allow ephemeral errorsawait interaction.deferReply().catch(() => { });try {const formKey = guildSelectedFormation.get(lineupGuildId) || 'default';const formation = formKey === `custom_${lineupGuildId}` ? guildCustomFormations.get(lineupGuildId) : FORMATIONS[formKey];const formDisplayName = formKey === `custom_${lineupGuildId}` ? (guildCustomFormationNames.get(lineupGuildId) || "Custom") : formKey;const attachment = await createLineupAttachment(lineupBoard, formDisplayName, formation || FORMATIONS["default"], client);const embed = UI.createEmbed(`⚽ Final Lineup — ${formDisplayName}`, "Here is the visual representation of the starting lineup.");embed.setImage('attachment://lineup.png');await interaction.editReply({ embeds: [embed], files: [attachment] });} catch (err) {console.error("Failed to generate lineup image:", err);await interaction.editReply({ content: "❌ Failed to generate lineup image. Please try again." }).catch(() => { });}return;}}37 unmodified lines383940414243441895 unmodified lines19401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198737 unmodified linesconst guildActiveCategory = new Map(); // Stores the currently selected category in the UI for each guildtry {const { createLineupAttachment, renderLineupImage } = require('./lineupRenderer');const { createProfileAttachment } = require('./profileRenderer');const { TACTICS, createTacticAttachment } = require('./tacticRenderer');global.createLineupAttachment = createLineupAttachment;1895 unmodified linesreturn interaction.reply({ content: `❌ Only <@${ownerId}> can generate the final image!`, flags: [MessageFlags.Ephemeral] });}await interaction.deferReply().catch(() => { });try {const formKey = guildSelectedFormation.get(lineupGuildId) || 'default';const formation = formKey === `custom_${lineupGuildId}` ? guildCustomFormations.get(lineupGuildId) : FORMATIONS[formKey];const formDisplayName = formKey === `custom_${lineupGuildId}` ? (guildCustomFormationNames.get(lineupGuildId) || "Custom") : formKey;const effFormation = formation || FORMATIONS["default"];const isScrim = guildScrimMode.get(lineupGuildId) === true;if (isScrim) {const teamABuffer = await renderLineupImage(lineupBoard, `TEAM A - ${formDisplayName}`, effFormation, client);const lineupB = getGuildLineupB(lineupGuildId);const teamBBuffer = await renderLineupImage(lineupB, `TEAM B - ${formDisplayName}`, effFormation, client, true);const attA = new AttachmentBuilder(teamABuffer, { name: 'team_a.png' });const attB = new AttachmentBuilder(teamBBuffer, { name: 'team_b.png' });const embedA = new EmbedBuilder().setColor('#5865F2').setTitle(`TEAM A — ${formDisplayName}`).setDescription('Team A lineup (attacking upward)').setImage('attachment://team_a.png');const embedB = new EmbedBuilder().setColor('#ff4444').setTitle(`TEAM B — ${formDisplayName}`).setDescription('Team B lineup (attacking downward, facing Team A)').setImage('attachment://team_b.png');await interaction.editReply({ embeds: [embedA, embedB], files: [attA, attB] });} else {const attachment = await createLineupAttachment(lineupBoard, formDisplayName, effFormation, client);const embed = UI.createEmbed(`⚽ Final Lineup — ${formDisplayName}`, "Here is the visual representation of the starting lineup.");embed.setImage('attachment://lineup.png');await interaction.editReply({ embeds: [embed], files: [attachment] });}} catch (err) {console.error("Failed to generate lineup image:", err);await interaction.editReply({ content: "❌ Failed to generate lineup image. Please try again." }).catch(() => { });}return;}}
index.js+41-16