Added a way to catch errors on command execution
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
720a0596dd
commit
3632e77b0b
@ -49,7 +49,10 @@ public final class DiscordManager {
|
||||
discordClient.getEventDispatcher().on(MessageCreateEvent.class)
|
||||
.filter(event -> event.getMessage().getAuthor().map(user -> !user.isBot()).orElse(false))
|
||||
.filter(event -> event.getMessage().getContent().split(" ")[0].equals(command.getName()))
|
||||
.flatMap(event -> !isInMaintenanceMode() ? command.execute(event).then() : Mono.just("").then())
|
||||
.flatMap(event -> !isInMaintenanceMode() ? command.execute(event).then() : Mono.empty())
|
||||
.doOnError(e -> logger.warn("An error occurred while executing a command " +
|
||||
"('" + command.getName() + "'):", e))
|
||||
.onErrorResume(e -> Mono.empty())
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user