Spaces:
Running
Running
Update lineup_persistence.js
Browse files- lineup_persistence.js +33 -26
lineup_persistence.js
CHANGED
|
@@ -19,20 +19,22 @@ let guildCustomFormations = new Map();
|
|
| 19 |
let guildCustomFormationNames = new Map();
|
| 20 |
let guildPingType = new Map();
|
| 21 |
let guildFriendlyPingType = new Map();
|
|
|
|
| 22 |
|
| 23 |
function save() {
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
for (const [guildId, lineupMap] of guildLineups) {
|
| 38 |
data.guildLineups[guildId] = Object.fromEntries(lineupMap);
|
|
@@ -89,11 +91,15 @@ function load() {
|
|
| 89 |
for (const [k, v] of Object.entries(data.guildPingType)) guildPingType.set(k, v);
|
| 90 |
}
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
-
|
| 97 |
} catch (e) {
|
| 98 |
console.error('[LINEUP PERSISTENCE] Load failed:', e.message);
|
| 99 |
}
|
|
@@ -103,14 +109,15 @@ function load() {
|
|
| 103 |
load();
|
| 104 |
|
| 105 |
module.exports = {
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
};
|
|
|
|
| 19 |
let guildCustomFormationNames = new Map();
|
| 20 |
let guildPingType = new Map();
|
| 21 |
let guildFriendlyPingType = new Map();
|
| 22 |
+
let guildScrimMode = new Map(); // Track if lineup is in scrim mode
|
| 23 |
|
| 24 |
function save() {
|
| 25 |
+
try {
|
| 26 |
+
const data = {
|
| 27 |
+
guildLineups: {},
|
| 28 |
+
guildSelectedFormation: Object.fromEntries(guildSelectedFormation),
|
| 29 |
+
lineupOwners: Object.fromEntries(lineupOwners),
|
| 30 |
+
activeLineupMessages: Object.fromEntries(activeLineupMessages),
|
| 31 |
+
managerBoards: Object.fromEntries(managerBoards),
|
| 32 |
+
guildCustomFormations: Object.fromEntries(guildCustomFormations),
|
| 33 |
+
guildCustomFormationNames: Object.fromEntries(guildCustomFormationNames),
|
| 34 |
+
guildPingType: Object.fromEntries(guildPingType),
|
| 35 |
+
guildFriendlyPingType: Object.fromEntries(guildFriendlyPingType),
|
| 36 |
+
guildScrimMode: Object.fromEntries(guildScrimMode)
|
| 37 |
+
};
|
| 38 |
|
| 39 |
for (const [guildId, lineupMap] of guildLineups) {
|
| 40 |
data.guildLineups[guildId] = Object.fromEntries(lineupMap);
|
|
|
|
| 91 |
for (const [k, v] of Object.entries(data.guildPingType)) guildPingType.set(k, v);
|
| 92 |
}
|
| 93 |
|
| 94 |
+
if (data.guildFriendlyPingType) {
|
| 95 |
+
for (const [k, v] of Object.entries(data.guildFriendlyPingType)) guildFriendlyPingType.set(k, v);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
if (data.guildScrimMode) {
|
| 99 |
+
for (const [k, v] of Object.entries(data.guildScrimMode)) guildScrimMode.set(k, v === "true" || v === true);
|
| 100 |
+
}
|
| 101 |
|
| 102 |
+
console.log('[LINEUP PERSISTENCE] Data loaded successfully.');
|
| 103 |
} catch (e) {
|
| 104 |
console.error('[LINEUP PERSISTENCE] Load failed:', e.message);
|
| 105 |
}
|
|
|
|
| 109 |
load();
|
| 110 |
|
| 111 |
module.exports = {
|
| 112 |
+
guildLineups,
|
| 113 |
+
guildSelectedFormation,
|
| 114 |
+
lineupOwners,
|
| 115 |
+
activeLineupMessages,
|
| 116 |
+
managerBoards,
|
| 117 |
+
guildCustomFormations,
|
| 118 |
+
guildCustomFormationNames,
|
| 119 |
+
guildPingType,
|
| 120 |
+
guildFriendlyPingType,
|
| 121 |
+
guildScrimMode,
|
| 122 |
+
save
|
| 123 |
};
|