add Passing debug server through env

This commit is contained in:
JOLIMAITRE Matthieu 2024-04-29 14:12:39 +02:00
parent 4b3db2c066
commit 2a8700ef04
2 changed files with 6 additions and 6 deletions

View file

@ -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.");