Fix shutdown method no longer shutting down when invocated directly
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bea 2023-01-16 02:11:16 +01:00
parent 383b09a53e
commit 7f73d4fb23

View File

@ -224,7 +224,7 @@ public class HidekoBot
} }
// register shutdown interrupt signal listener for proper shutdown. // register shutdown interrupt signal listener for proper shutdown.
Runtime.getRuntime().addShutdownHook(new Thread(HidekoBot::shutdown)); Runtime.getRuntime().addShutdownHook(new Thread(HidekoBot::preShutdown));
// set startup time. // set startup time.
Cache.setStartupTime(LocalDateTime.now()); Cache.setStartupTime(LocalDateTime.now());
@ -244,8 +244,15 @@ public class HidekoBot
} }
public static void shutdown() public static void shutdown()
{
preShutdown();
System.exit(0);
}
private static void preShutdown()
{ {
LOGGER.warn("WARNING! Shutting down!"); LOGGER.warn("WARNING! Shutting down!");
if(jda != null) jda.shutdown(); if(jda != null) jda.shutdown();
} }
} }