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

+7 -1
View File
@@ -302,7 +302,13 @@ export class Dashboard {
const authErr = await this._authorizeUserInGuild(user, voiceChannel.guildId);
if (authErr) return { error: authErr };
if (this.remix.players.playerMap.has(voiceChannel.id)) return { message: "Already Connected" };
const fakeMsg = { channel: { channel: textChannel, guildId: voiceChannel.guildId }, message: { guildId: voiceChannel.guildId } };
// Build a minimal fake message that satisfies PlayerManager.initPlayer().
// initPlayer calls message.reply() for status updates (joining, errors).
const fakeMsg = {
channel: { channel: textChannel, guildId: voiceChannel.guildId },
message: { guildId: voiceChannel.guildId },
reply: async () => ({ catch: () => {} }),
};
this.remix.players.initPlayer(fakeMsg, voiceChannel.id);
return { message: "Joining" };
}