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
|
* The request message sent in the voice channel
|
||||||
*/
|
*/
|
||||||
private Message requestMessage;
|
private Message requestMessage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cc.fascinated.bat.service;
|
package cc.fascinated.bat.service;
|
||||||
|
|
||||||
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.event.EventListener;
|
import cc.fascinated.bat.event.EventListener;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
@ -142,9 +143,19 @@ public class EventService extends ListenerAdapter {
|
|||||||
BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null;
|
BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null;
|
||||||
BatUser user = userService.getUser(event.getUser().getId());
|
BatUser user = userService.getUser(event.getUser().getId());
|
||||||
|
|
||||||
|
try {
|
||||||
for (EventListener listener : LISTENERS) {
|
for (EventListener listener : LISTENERS) {
|
||||||
listener.onButtonInteraction(guild, user, event);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -155,9 +166,19 @@ public class EventService extends ListenerAdapter {
|
|||||||
BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null;
|
BatGuild guild = event.getGuild() != null ? guildService.getGuild(event.getGuild().getId()) : null;
|
||||||
BatUser user = userService.getUser(event.getUser().getId());
|
BatUser user = userService.getUser(event.getUser().getId());
|
||||||
|
|
||||||
|
try {
|
||||||
for (EventListener listener : LISTENERS) {
|
for (EventListener listener : LISTENERS) {
|
||||||
listener.onModalInteraction(guild, user, event);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user