diff --git a/src/main/java/cc/fascinated/bat/features/drag/DragRequest.java b/src/main/java/cc/fascinated/bat/features/drag/DragRequest.java index 26bf4ba..c572eeb 100644 --- a/src/main/java/cc/fascinated/bat/features/drag/DragRequest.java +++ b/src/main/java/cc/fascinated/bat/features/drag/DragRequest.java @@ -45,5 +45,4 @@ public class DragRequest { * The request message sent in the voice channel */ private Message requestMessage; - } diff --git a/src/main/java/cc/fascinated/bat/service/EventService.java b/src/main/java/cc/fascinated/bat/service/EventService.java index 4fd2fcc..773d52b 100644 --- a/src/main/java/cc/fascinated/bat/service/EventService.java +++ b/src/main/java/cc/fascinated/bat/service/EventService.java @@ -1,5 +1,6 @@ package cc.fascinated.bat.service; +import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.event.EventListener; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; @@ -142,8 +143,18 @@ public class EventService extends ListenerAdapter { BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null; BatUser user = userService.getUser(event.getUser().getId()); - for (EventListener listener : LISTENERS) { - listener.onButtonInteraction(guild, user, event); + try { + for (EventListener listener : LISTENERS) { + listener.onButtonInteraction(guild, user, event); + } + } catch (Exception e) { + log.error("An error occurred while handling a modal interaction.", e); + if (event.isAcknowledged()) { + return; + } + event.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("An error occurred while handling your interaction.\nError: ```java\n%s\n```".formatted(e.getMessage())) + .build()).queue(); } } @@ -155,8 +166,18 @@ public class EventService extends ListenerAdapter { BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null; BatUser user = userService.getUser(event.getUser().getId()); - for (EventListener listener : LISTENERS) { - listener.onModalInteraction(guild, user, event); + try { + for (EventListener listener : LISTENERS) { + listener.onModalInteraction(guild, user, event); + } + } catch (Exception e) { + log.error("An error occurred while handling a modal interaction.", e); + if (event.isAcknowledged()) { + return; + } + event.replyEmbeds(EmbedUtils.errorEmbed() + .setDescription("An error occurred while handling your interaction.\nError: ```java\n%s\n```".formatted(e.getMessage())) + .build()).queue(); } }