Refactor DiscordBotInstance to initialize JDA lazily and standardize "Discord ID" terminology in appeal form.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user