diff --git a/src/bot.ts b/src/bot.ts index ce9eb0b..c28ddbe 100755 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,7 +1,5 @@ #!/bin/env -S deno run -A --unstable-kv -import * as fs from "node:fs"; - import { Client } from "npm:discord.js"; import { Storage } from "./lib/storage.ts"; @@ -10,9 +8,7 @@ import { update_loop } from "./lib/board.ts"; import { notification_loop } from "./lib/notification.ts"; import { declare_commands, handle_autocomplete, handle_command } from "./lib/commands/commands.ts"; - const log = log_from(import.meta); -const subjects = new Set(fs.readFileSync('/modules.conf', 'utf-8').split('\n')); async function main() { const debug_server = Deno.env.get("DEBUG"); @@ -33,7 +29,7 @@ async function main() { await bot.login(token); log("Logged in as", bot.user?.username); - const commands = declare_commands(subjects); + const commands = declare_commands(await read_subjects()); if (debug_server !== undefined) { for (const command of commands) command.setName("dbg-" + command.name); await bot.application?.commands.set(commands, debug_server); @@ -49,4 +45,10 @@ async function main() { log("Oki."); } +async function read_subjects() { + const content = await Deno.readTextFile("./modules.conf"); + const subjects = content.split("\n").filter((l) => l !== ""); + return new Set(subjects); +} + if (import.meta.main) await main();