[BUG] Additional safety check to prevent messages from being sent when SHUTDOWN has been called
This commit is contained in:
@@ -49,6 +49,7 @@ public class BotController {
|
|||||||
|
|
||||||
// Required Variables
|
// Required Variables
|
||||||
private JDA _jda;
|
private JDA _jda;
|
||||||
|
private boolean shutdownCalled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* INTERNAL
|
* INTERNAL
|
||||||
@@ -101,6 +102,8 @@ public class BotController {
|
|||||||
* Start the bot and handle all the startup work
|
* Start the bot and handle all the startup work
|
||||||
*/
|
*/
|
||||||
public void initializeBot() {
|
public void initializeBot() {
|
||||||
|
shutdownCalled = false;
|
||||||
|
|
||||||
if (SDLinkConfig.INSTANCE == null || !SDLinkConfig.hasConfigLoaded) {
|
if (SDLinkConfig.INSTANCE == null || !SDLinkConfig.hasConfigLoaded) {
|
||||||
logger.error("Failed to load config. Check your log for errors");
|
logger.error("Failed to load config. Check your log for errors");
|
||||||
return;
|
return;
|
||||||
@@ -156,6 +159,9 @@ public class BotController {
|
|||||||
if (SDLinkConfig.INSTANCE == null)
|
if (SDLinkConfig.INSTANCE == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (shutdownCalled)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!SDLinkConfig.INSTANCE.generalConfig.enabled)
|
if (!SDLinkConfig.INSTANCE.generalConfig.enabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -181,6 +187,7 @@ public class BotController {
|
|||||||
* @param forced Should the shutdown be forced
|
* @param forced Should the shutdown be forced
|
||||||
*/
|
*/
|
||||||
public void shutdownBot(boolean forced) {
|
public void shutdownBot(boolean forced) {
|
||||||
|
shutdownCalled = true;
|
||||||
if (_jda != null) {
|
if (_jda != null) {
|
||||||
_jda.shutdown();
|
_jda.shutdown();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user