fix: resolve startup crashes from missing exports, unsafe JSON parsing, and broken migrate/dashboard logic

Full rework and bugfix pass across the fluxer codebase to resolve
multiple runtime crashes that prevented the bot from starting and
loading guild settings correctly.

Export/Import Fixes:
- Added re-export of SettingsManager from settings/Settings.mjs
  into src/Settings.mjs to resolve missing named export error
  that crashed the bot on startup (affected CommandHandler,
  PlayerManager, and migrate.mjs)
- Verified all 70+ import/export chains across the entire project

JSON.parse Safety (mysql2 JSON column handling):
- src/Settings.mjs — added typeof guard before JSON.parse on
  RemoteSettingsManager.load() since mysql2 returns JSON columns
  as already-parsed objects, causing "[object Object]" SyntaxError
- settings/Settings.mjs — same typeof guard applied
- src/GatewayHandler.mjs — same typeof guard applied

Migrate Script Fix:
- settings/migrate.mjs — replaced abstract SettingsManager usage
  with concrete RemoteSettingsManager (which actually has the
  `guilds` property required for migration logic)

Dashboard Fix:
- src/dashboard/Dashboard.mjs — added missing reply() method to
  fakeMsg object so PlayerManager.initPlayer() doesn't crash when
  a user joins voice through the web dashboard

Files changed (13):
- src/Settings.mjs
- settings/Settings.mjs
- src/GatewayHandler.mjs
- settings/migrate.mjs
- src/dashboard/Dashboard.mjs
- src/CommandHandler.mjs
- src/PlayerManager.mjs
- src/MoonlinkManager.mjs
- src/Player.mjs
- src/RecoveryManager.mjs
- src/constants/audio/StreamMerger.mjs
- src/constants/audio/Tuna.mjs
- commands/remove.mjs
This commit is contained in:
NoLogicAlan committed 2026-05-06 23:33:57 +03:00
1 parent 5e0aefb79d
commit 991045f4dd
13 files changed
+1361 -1327

No files matched your search

+12 -2
View File
@@ -21,8 +21,18 @@ class Tuna {
var req = https.request(options, function(res) {
var chunks = [];
res.on("data", (chunk) => { chunks.push(chunk); });
res.on("end", () => { resolve(JSON.parse(Buffer.concat(chunks).toString())); });
res.on("error", (error) => { rej(error); });
res.on("end", () => {
try {
resolve(JSON.parse(Buffer.concat(chunks).toString()));
} catch (e) {
rej(new Error(`Tuna API JSON parse error: ${e.message}`));
}
});
});
req.on("error", (error) => { rej(error); });
req.setTimeout(15_000, () => {
req.destroy();
rej(new Error("Tuna API request timeout"));
});
req.end();
});