Save announcer voice across restarts

This commit is contained in:
2026-05-14 21:26:10 +02:00
parent ffb229b513
commit f56e6079e6
2 changed files with 26 additions and 3 deletions
+11 -1
View File
@@ -8,6 +8,7 @@ process.on("uncaughtException", (err) => {
console.error("Uncaught exception:", err);
});
import { openDatabase } from "./db/db.js";
import type { BotStateRow } from "./db/schema.js";
import { loadStrings, makeT } from "./i18n/strings.js";
import { TTSRegistry } from "./tts/registry.js";
import { AudioService } from "./audio/AudioService.js";
@@ -31,7 +32,16 @@ client.on(Events.Error, (err) => console.error("Discord client error:", err));
client.on(Events.Warn, (msg) => console.warn("Discord client warning:", msg));
const db = await openDatabase(config.DB_FILE);
const tts = new TTSRegistry(config.ANNOUNCEMENT_ENGINE, config.ANNOUNCEMENT_VOICE);
const savedEngine = await db.get<BotStateRow>(
"select value from BotState where key='announcement_engine'",
);
const savedVoice = await db.get<BotStateRow>(
"select value from BotState where key='announcement_voice'",
);
const tts = new TTSRegistry(
savedEngine?.value ?? config.ANNOUNCEMENT_ENGINE,
savedVoice?.value ?? config.ANNOUNCEMENT_VOICE,
);
const audio = new AudioService({ voiceTmpPath: config.VOICE_TMP_PATH, tts });
const commands = new CommandRegistry(config.PREFIX);
const strings = loadStrings(config.STRING_SET);