Refactor DiscordBotInstance to initialize JDA lazily and standardize "Discord ID" terminology in appeal form.

This commit is contained in:
2025-11-23 03:34:20 +01:00
parent 7d59885395
commit af9e1e627f
2 changed files with 21 additions and 5 deletions
@@ -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;