fix: stopping stuff in Main and IRCPlugin

This commit is contained in:
Chayapak 2024-11-12 16:43:45 +07:00
parent 4ba78b843b
commit 5e9a1f0917
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
2 changed files with 8 additions and 4 deletions

View file

@ -43,6 +43,8 @@ public class Main {
private static boolean alreadyStarted = false;
private static boolean stopping = false;
private static final List<Thread> 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();
}

View file

@ -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) {