From 3416c13f10d66483124580171600a732f57d73ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Fri, 26 Aug 2022 03:48:15 +0200 Subject: [PATCH] Add small delay before shutdown --- .../beatrice/hidekobot/listeners/MessageListener.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/listeners/MessageListener.java b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageListener.java index b5acafb..b5c0aa2 100644 --- a/src/main/java/wtf/beatrice/hidekobot/listeners/MessageListener.java +++ b/src/main/java/wtf/beatrice/hidekobot/listeners/MessageListener.java @@ -10,6 +10,8 @@ import wtf.beatrice.hidekobot.utils.RandomUtil; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; public class MessageListener extends ListenerAdapter { @@ -87,15 +89,18 @@ public class MessageListener extends ListenerAdapter return; } - if(eventMessage.equalsIgnoreCase("hideko die")) { MessageChannel channel = event.getChannel(); channel.sendMessage("Going to sleep! Cya :sparkles:").queue(); - HidekoBot.getAPI().shutdown(); - System.exit(0); + Executors.newSingleThreadScheduledExecutor().schedule(() -> + { + HidekoBot.getAPI().shutdown(); + System.exit(0); + }, 5, TimeUnit.SECONDS); + return; } }