diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java index c0223d1..3ffac41 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/DiscordPlugin.java @@ -86,7 +86,9 @@ public class DiscordPlugin { bot.tick.addListener(new TickPlugin.Listener() { @Override public void onAlwaysTick () { - onDiscordTick(channelId); + try { + onDiscordTick(channelId); + } catch (Exception ignored) {} } }); diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/TickPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/TickPlugin.java index 4f2fbe0..0a019e5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/TickPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/TickPlugin.java @@ -18,11 +18,25 @@ public class TickPlugin { } private void tick () { - for (Listener listener : listeners) listener.onAlwaysTick(); + for (Listener listener : listeners) { + try { + listener.onAlwaysTick(); + } catch (Exception e) { + bot.logger.error("Caught exception in an always tick listener!"); + e.printStackTrace(); + } + } if (!bot.loggedIn) return; - for (Listener listener : listeners) listener.onTick(); + for (Listener listener : listeners) { + try { + listener.onTick(); + } catch (Exception e) { + bot.logger.error("Caught exception in a tick listener!"); + e.printStackTrace(); + } + } } public void addListener (Listener listener) {