mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
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:
1 parent
5e0aefb79d
commit
991045f4dd
13 files changed
+1361
-1327
No files matched your search
+11
-4
@@ -1,13 +1,20 @@
|
||||
import { SettingsManager, RemoteSettingsManager } from "./Settings.mjs";
|
||||
import { SettingsManager, RemoteSettingsManager } from "../src/Settings.mjs";
|
||||
import fs from "node:fs";
|
||||
import { logger } from "../src/constants/Logger.mjs";
|
||||
|
||||
const config = JSON.parse(fs.readFileSync(new URL("../config.json", import.meta.url)));
|
||||
|
||||
const sm = new SettingsManager();
|
||||
const rsm = new RemoteSettingsManager(config.mysql);
|
||||
// Both source and destination use RemoteSettingsManager to ensure the
|
||||
// `guilds` Map is populated from MySQL. The abstract SettingsManager base
|
||||
// class has no implementation (no guilds, no load, no defaults).
|
||||
const sm = new RemoteSettingsManager(config.mysql, "./storage/defaults.json");
|
||||
const rsm = new RemoteSettingsManager(config.mysql, "./storage/defaults.json");
|
||||
|
||||
const servers = sm.guilds.entries();
|
||||
// Capture entries after the source manager has loaded from DB.
|
||||
let servers = [];
|
||||
sm.on("ready", () => {
|
||||
servers = sm.guilds.entries();
|
||||
});
|
||||
|
||||
rsm.on("ready", async () => {
|
||||
for (const [id, s] of servers) {
|
||||
|
||||
Reference in new issue
Block a user