diff --git a/run.sh b/run.sh index 460fd18..1a0cc0f 100755 --- a/run.sh +++ b/run.sh @@ -6,4 +6,4 @@ if ! [ -f ./token ] then echo "ERROR : Needs discord API token in ./token" && exit fi -./src/bot.ts ./token +DEBUG=871777993922588712 ./src/bot.ts ./token diff --git a/src/bot.ts b/src/bot.ts index 61f09d8..3df5cd7 100755 --- a/src/bot.ts +++ b/src/bot.ts @@ -30,7 +30,8 @@ const subjects = new Set([ ]); async function main() { - const is_debug = Deno.env.has("DEBUG"); + const debug_server = Deno.env.get("DEBUG"); + if (debug_server !== undefined) log("Starting in debug mode on server", debug_server); const [token_file] = Deno.args; const token = (await Deno.readTextFile(token_file)).trim(); @@ -48,12 +49,11 @@ async function main() { log("Logged in as", bot.user?.username); const commands = build_api_commands(subjects); - if (is_debug) { - await bot.application?.commands.set([]); - await bot.application?.commands.set(commands, "871777993922588712"); + if (debug_server !== undefined) { + for (const command of commands) command.setName("dbg-" + command.name); + await bot.application?.commands.set(commands, debug_server); } else { await bot.application?.commands.set(commands); - await bot.application?.commands.set([], "871777993922588712"); } log("Registered", commands.length, "commands.");