From 771e115bbd5e2b16b196383042fafaf104686dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Sun, 20 Nov 2022 03:25:51 +0100 Subject: [PATCH] Update startup method Small changes to improve stability and readability. --- src/main/java/wtf/beatrice/hidekobot/HidekoBot.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java index 4bbfa35..c5b59a1 100644 --- a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java +++ b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java @@ -61,7 +61,7 @@ public class HidekoBot } catch (LoginException | InterruptedException e) { logger.log(e.getMessage()); // print the error message, omit the stack trace. - return; // if we failed connecting and authenticating, then quit. + shutdown(); // if we failed connecting and authenticating, then quit. } // find the bot's user id and generate an invite-link. @@ -73,7 +73,7 @@ public class HidekoBot jda.addEventListener(new SlashCommandListener()); // update slash commands (delayed) - Executors.newSingleThreadScheduledExecutor().schedule(SlashCommandsUtil::updateSlashCommands, 5, TimeUnit.SECONDS); + Executors.newSingleThreadScheduledExecutor().schedule(SlashCommandsUtil::updateSlashCommands, 1, TimeUnit.SECONDS); // set the bot's status jda.getPresence().setStatus(OnlineStatus.ONLINE); @@ -106,7 +106,7 @@ public class HidekoBot public static void shutdown() { logger.log("WARNING! Shutting down!"); - jda.shutdown(); + if(jda != null) jda.shutdown(); System.exit(0); }