handle errors on interactions
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
This commit is contained in:
parent
2fcc1b66c1
commit
750b8cbfea
@ -45,5 +45,4 @@ public class DragRequest {
|
||||
* The request message sent in the voice channel
|
||||
*/
|
||||
private Message requestMessage;
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user