[BUG] Additional safety check to prevent messages from being sent when SHUTDOWN has been called

This commit is contained in:
2024-03-17 13:41:47 +02:00
parent 4e2f037c2f
commit 921a109338

View File

@@ -49,6 +49,7 @@ public class BotController {
// Required Variables
private JDA _jda;
private boolean shutdownCalled = false;
/**
* INTERNAL
@@ -101,6 +102,8 @@ public class BotController {
* Start the bot and handle all the startup work
*/
public void initializeBot() {
shutdownCalled = false;
if (SDLinkConfig.INSTANCE == null || !SDLinkConfig.hasConfigLoaded) {
logger.error("Failed to load config. Check your log for errors");
return;
@@ -156,6 +159,9 @@ public class BotController {
if (SDLinkConfig.INSTANCE == null)
return false;
if (shutdownCalled)
return false;
if (!SDLinkConfig.INSTANCE.generalConfig.enabled)
return false;
@@ -181,6 +187,7 @@ public class BotController {
* @param forced Should the shutdown be forced
*/
public void shutdownBot(boolean forced) {
shutdownCalled = true;
if (_jda != null) {
_jda.shutdown();
}