Ensure JDA is started before allowing calls to the JDA object

This commit is contained in:
Josh Roy 2021-11-25 11:54:14 -05:00
parent 51c49b0de6
commit 668c9634ca

View File

@ -149,9 +149,9 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
public void startup() throws LoginException, InterruptedException {
shutdown();
invalidStartup = true;
logger.log(Level.INFO, tl("discordLoggingIn"));
if (plugin.getSettings().getBotToken().replace("INSERT-TOKEN-HERE", "").trim().isEmpty()) {
invalidStartup = true;
throw new IllegalArgumentException(tl("discordErrorNoToken"));
}
@ -162,6 +162,7 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
.setContextEnabled(false)
.build()
.awaitReady();
invalidStartup = false;
updatePresence();
logger.log(Level.INFO, tl("discordLoggingInDone", jda.getSelfUser().getAsTag()));