From af9e1e627fae90fe43dfae497b15599a035c34c0 Mon Sep 17 00:00:00 2001 From: akastijn Date: Sun, 23 Nov 2025 03:34:20 +0100 Subject: [PATCH] Refactor `DiscordBotInstance` to initialize `JDA` lazily and standardize "Discord ID" terminology in appeal form. --- .../webinterface/bot/DiscordBotInstance.java | 18 +++++++++++++++++- .../discord-appeal.component.html | 8 ++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/discord/src/main/java/com/alttd/webinterface/bot/DiscordBotInstance.java b/discord/src/main/java/com/alttd/webinterface/bot/DiscordBotInstance.java index 115eaa3..0425d10 100644 --- a/discord/src/main/java/com/alttd/webinterface/bot/DiscordBotInstance.java +++ b/discord/src/main/java/com/alttd/webinterface/bot/DiscordBotInstance.java @@ -17,10 +17,26 @@ public class DiscordBotInstance { private DiscordBotInstance() {} - @Getter private JDA jda; private volatile boolean ready = false; + public JDA getJda() { + if (jda == null) { + String discordToken = System.getProperty("DISCORD_TOKEN"); + if (discordToken == null) { + log.error("Discord token not found, put it in the DISCORD_TOKEN environment variable"); + System.exit(1); + } + start(discordToken); + try { + jda.awaitReady(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + return jda; + } + public synchronized void start(String token) { if (jda != null) { return; diff --git a/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.html b/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.html index 5e55a95..23aa203 100644 --- a/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.html +++ b/frontend/src/app/pages/forms/discord-appeal/discord-appeal.component.html @@ -41,15 +41,15 @@ @if (currentPageIndex === 2) {
-

Please enter your discord id below.

-

You can find your discord id by going to User settings -> Advanced -> Developer Mode and turning it +

Please enter your Discord ID below.

+

You can find your Discord ID by going to User settings -> Advanced -> Developer Mode and turning it on

-

With Developer Mode on in Discord click your profile in the bottom left and click Copy User Id

+

With Developer Mode on in Discord click your profile in the bottom left and click Copy User ID

We use this to find your punishment on our Discord server.

Discord Id -