diff --git a/src/main/java/me/chayapak1/chomens_bot/Main.java b/src/main/java/me/chayapak1/chomens_bot/Main.java index e5234bd..34c6729 100644 --- a/src/main/java/me/chayapak1/chomens_bot/Main.java +++ b/src/main/java/me/chayapak1/chomens_bot/Main.java @@ -43,6 +43,8 @@ public class Main { private static boolean alreadyStarted = false; + private static boolean stopping = false; + private static final List alreadyAddedThreads = new ArrayList<>(); private static JDA jda = null; @@ -187,6 +189,10 @@ public class Main { // most of these are stolen from HBot public static void stop () { + if (stopping) return; + + stopping = true; + executor.shutdown(); PersistentDataUtilities.stop(); @@ -215,9 +221,7 @@ public class Main { bot.discord.sendMessageInstantly("Stopping..", channelId); } - if (ircEnabled) { - bot.irc.quit("Stopping.."); - } + if (ircEnabled) bot.irc.quit("Stopping.."); bot.stop(); } diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java index 6de3957..6c6a172 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/IRCPlugin.java @@ -169,7 +169,7 @@ public class IRCPlugin extends ListenerAdapter { } public void quit (String reason) { - bot.sendIRC().quitServer(reason); + if (bot.isConnected()) bot.sendIRC().quitServer(reason); } private void connected (Bot bot) {