add Passing debug server through env
This commit is contained in:
parent
4b3db2c066
commit
2a8700ef04
2 changed files with 6 additions and 6 deletions
2
run.sh
2
run.sh
|
@ -6,4 +6,4 @@ if ! [ -f ./token ]
|
||||||
then echo "ERROR : Needs discord API token in ./token" && exit
|
then echo "ERROR : Needs discord API token in ./token" && exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./src/bot.ts ./token
|
DEBUG=871777993922588712 ./src/bot.ts ./token
|
||||||
|
|
10
src/bot.ts
10
src/bot.ts
|
@ -30,7 +30,8 @@ const subjects = new Set([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
async function main() {
|
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_file] = Deno.args;
|
||||||
const token = (await Deno.readTextFile(token_file)).trim();
|
const token = (await Deno.readTextFile(token_file)).trim();
|
||||||
|
|
||||||
|
@ -48,12 +49,11 @@ async function main() {
|
||||||
log("Logged in as", bot.user?.username);
|
log("Logged in as", bot.user?.username);
|
||||||
|
|
||||||
const commands = build_api_commands(subjects);
|
const commands = build_api_commands(subjects);
|
||||||
if (is_debug) {
|
if (debug_server !== undefined) {
|
||||||
await bot.application?.commands.set([]);
|
for (const command of commands) command.setName("dbg-" + command.name);
|
||||||
await bot.application?.commands.set(commands, "871777993922588712");
|
await bot.application?.commands.set(commands, debug_server);
|
||||||
} else {
|
} else {
|
||||||
await bot.application?.commands.set(commands);
|
await bot.application?.commands.set(commands);
|
||||||
await bot.application?.commands.set([], "871777993922588712");
|
|
||||||
}
|
}
|
||||||
log("Registered", commands.length, "commands.");
|
log("Registered", commands.length, "commands.");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue