Files
fluxer/settings/migrate.mjs
T
NoLogicAlan 092268281a refactor: centralize shared utilities, fix voice intent, and improve error visibility
- extract `cleanId()` to `Utils.mjs` and remove 97+ inline `String(x).replace(/\D/g, "")` duplicates

- add `VoiceStateResolver.mjs` with `iterateVoiceStates`, `hasHumansInChannel`, `getChannelsWithHumans` — eliminates 12+ duplicated voice-state-iteration blocks across `Player`, `PlayerManager`, `GatewayHandler`, `Dashboard`

- add `UI.mjs` for shared color, emoji, and timeout constants

- move `parseInlineProvider` to `providers.mjs`, `getMessageGuildId` to `MessageHandler.mjs`

- fix `VoiceStateCache.removeGuild` and `TrackOptionsManager` cache deletion mutating Maps during iteration

- fix `checkVoiceChannels` now async returning `{channelId, alreadyInVoice, hasHumans}` — all callers updated

- fix `FluxerRevoice` global `console.log` monkey-patch replaced with scoped `withSuppressedLiveKitLogs(fn)`

- fix `Player._get247Mode()` settings resolution chain

- fix `runnables.mjs` validators were no-ops

- promote `Player` magic numbers to named static constants

- replace all silent `catch (_) {}` with `logger.warn()` throughout

- remove unused deps: `express`, `genius-lyrics`, `ws`

- add `@file` JSDoc headers to all modules
2026-06-15 16:56:10 +03:00

39 lines
1.1 KiB
JavaScript

/**
* @file migrate.mjs — Migration script — migrates settings and 24/7 channel data between Redis and SQLite backends
* @module settings.migrate
*/
import { 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 botId = config.botId ?? null;
const sm = new RemoteSettingsManager(config.mysql, "./storage/defaults.json", botId);
const rsm = new RemoteSettingsManager(config.mysql, "./storage/defaults.json", botId);
let migrationStarted = false;
sm.on("ready", async () => {
if (migrationStarted) return;
migrationStarted = true;
const servers = [...sm.guilds.entries()];
if (!rsm.guilds.size) {
await new Promise(resolve => rsm.on("ready", resolve));
}
for (const [id, s] of servers) {
logger.settings("[migrate] Processing server:", id);
if (rsm.hasServer(id)) {
await rsm.remoteSave(s);
continue;
}
await rsm.create(id, s);
}
process.exit(0);
});