Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -34,7 +34,7 @@ console.log(">>> [BOOT] Loading Web Server module...");
|
|
| 34 |
const server = require('./server');
|
| 35 |
console.log(">>> [BOOT] Web Server module loaded.");
|
| 36 |
|
| 37 |
-
const { guildLineups, guildLineupsB, guildScrimMode, guildSelectedFormationA, guildSelectedFormationB, lineupOwners, activeLineupMessages, managerBoards, guildCustomFormations, guildCustomFormationNames, guildPingType, guildFriendlyPingType, save: saveLineup } = require('./lineup_persistence');
|
| 38 |
const guildActiveCategory = new Map(); // Stores the currently selected category in the UI for each guild
|
| 39 |
|
| 40 |
try {
|
|
@@ -1061,7 +1061,13 @@ Tip: All commands support Discord Slash Commands (/) for a better experience!`;
|
|
| 1061 |
const waitMsg = await message.reply('⏳ **Generating lineup image...**');
|
| 1062 |
try {
|
| 1063 |
const lineup = getGuildLineup(message.guildId);
|
| 1064 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1065 |
const formation = formKey === `custom_${message.guildId}` ? guildCustomFormations.get(message.guildId) : FORMATIONS[formKey];
|
| 1066 |
const formDisplayName = formKey === `custom_${message.guildId}` ? (guildCustomFormationNames.get(message.guildId) || "Custom") : formKey;
|
| 1067 |
|
|
@@ -2534,7 +2540,15 @@ function getFriendlyText(guildId, needed) {
|
|
| 2534 |
|
| 2535 |
function createLineupView(guildId) {
|
| 2536 |
const lineup = getGuildLineup(guildId);
|
| 2537 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2538 |
const formation = formKey === `custom_${guildId}` ? guildCustomFormations.get(guildId) : FORMATIONS[formKey];
|
| 2539 |
const formDisplayName = formKey === `custom_${guildId}` ? (guildCustomFormationNames.get(guildId) || "Custom") : formKey;
|
| 2540 |
|
|
|
|
| 34 |
const server = require('./server');
|
| 35 |
console.log(">>> [BOOT] Web Server module loaded.");
|
| 36 |
|
| 37 |
+
const { guildLineups, guildLineupsB, guildScrimMode, guildSelectedFormationA, guildSelectedFormationB, guildSelectedFormation, lineupOwners, activeLineupMessages, managerBoards, guildCustomFormations, guildCustomFormationNames, guildPingType, guildFriendlyPingType, save: saveLineup } = require('./lineup_persistence');
|
| 38 |
const guildActiveCategory = new Map(); // Stores the currently selected category in the UI for each guild
|
| 39 |
|
| 40 |
try {
|
|
|
|
| 1061 |
const waitMsg = await message.reply('⏳ **Generating lineup image...**');
|
| 1062 |
try {
|
| 1063 |
const lineup = getGuildLineup(message.guildId);
|
| 1064 |
+
// Robust formKey resolution for text-based lineup as fallback if the map isn't available
|
| 1065 |
+
let formKey;
|
| 1066 |
+
if (typeof guildSelectedFormation !== 'undefined' && guildSelectedFormation && typeof guildSelectedFormation.get === 'function') {
|
| 1067 |
+
formKey = guildSelectedFormation.get(message.guildId) || 'default';
|
| 1068 |
+
} else {
|
| 1069 |
+
formKey = (guildSelectedFormationA && guildSelectedFormationA.get(message.guildId)) || (guildSelectedFormationB && guildSelectedFormationB.get(message.guildId)) || 'default';
|
| 1070 |
+
}
|
| 1071 |
const formation = formKey === `custom_${message.guildId}` ? guildCustomFormations.get(message.guildId) : FORMATIONS[formKey];
|
| 1072 |
const formDisplayName = formKey === `custom_${message.guildId}` ? (guildCustomFormationNames.get(message.guildId) || "Custom") : formKey;
|
| 1073 |
|
|
|
|
| 2540 |
|
| 2541 |
function createLineupView(guildId) {
|
| 2542 |
const lineup = getGuildLineup(guildId);
|
| 2543 |
+
// Prefer explicit map if present; otherwise fall back to A/B maps or default
|
| 2544 |
+
let formKey;
|
| 2545 |
+
if (typeof guildSelectedFormation !== 'undefined' && guildSelectedFormation && typeof guildSelectedFormation.get === 'function') {
|
| 2546 |
+
formKey = guildSelectedFormation.get(guildId) || 'default';
|
| 2547 |
+
} else {
|
| 2548 |
+
const kb = (guildSelectedFormationA && guildSelectedFormationA.get(guildId)) || null;
|
| 2549 |
+
const kb2 = (guildSelectedFormationB && guildSelectedFormationB.get(guildId)) || null;
|
| 2550 |
+
formKey = kb || kb2 || 'default';
|
| 2551 |
+
}
|
| 2552 |
const formation = formKey === `custom_${guildId}` ? guildCustomFormations.get(guildId) : FORMATIONS[formKey];
|
| 2553 |
const formDisplayName = formKey === `custom_${guildId}` ? (guildCustomFormationNames.get(guildId) || "Custom") : formKey;
|
| 2554 |
|