From 74d55d81cad1f1e89b4b8fb3c30dc52418a3d5f0 Mon Sep 17 00:00:00 2001 From: Tueem Date: Thu, 19 Dec 2024 21:12:36 +0100 Subject: [PATCH] add remaining logging in Javacord wrapper and exceptions --- .../marinara/interaction/methods/InteractionMethod.java | 2 +- .../marinara/wrapper/javacord/JavacordWrapper.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/src/main/java/net/tomatentum/marinara/interaction/methods/InteractionMethod.java b/lib/src/main/java/net/tomatentum/marinara/interaction/methods/InteractionMethod.java index 437b2de..06112ca 100644 --- a/lib/src/main/java/net/tomatentum/marinara/interaction/methods/InteractionMethod.java +++ b/lib/src/main/java/net/tomatentum/marinara/interaction/methods/InteractionMethod.java @@ -73,7 +73,7 @@ public abstract class InteractionMethod { try { method.invoke(handler, getParameters(context)); }catch (IllegalAccessException | InvocationTargetException ex) { - throw new RuntimeException(ex); + logger.fatal(ex); } this.appliedChecks.forEach(x -> x.post(context)); diff --git a/wrapper/javacord/src/main/java/net/tomatentum/marinara/wrapper/javacord/JavacordWrapper.java b/wrapper/javacord/src/main/java/net/tomatentum/marinara/wrapper/javacord/JavacordWrapper.java index 98988df..ba540e6 100644 --- a/wrapper/javacord/src/main/java/net/tomatentum/marinara/wrapper/javacord/JavacordWrapper.java +++ b/wrapper/javacord/src/main/java/net/tomatentum/marinara/wrapper/javacord/JavacordWrapper.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.logging.log4j.Logger; import org.javacord.api.DiscordApi; import org.javacord.api.interaction.ApplicationCommandInteraction; import org.javacord.api.interaction.ButtonInteraction; @@ -25,15 +26,19 @@ import net.tomatentum.marinara.interaction.commands.annotation.SlashCommandOptio import net.tomatentum.marinara.interaction.commands.annotation.SubCommand; import net.tomatentum.marinara.interaction.commands.annotation.SubCommandGroup; import net.tomatentum.marinara.interaction.commands.option.SlashCommandOptionType; +import net.tomatentum.marinara.util.LoggerUtil; import net.tomatentum.marinara.wrapper.LibraryWrapper; public class JavacordWrapper extends LibraryWrapper { private DiscordApi api; + private Logger logger = LoggerUtil.getLogger(getClass()); + public JavacordWrapper(DiscordApi api) { this.api = api; api.addInteractionCreateListener((e) -> handleInteraction(e.getInteraction())); + logger.info("Javacord wrapper loaded!"); } @Override @@ -99,7 +104,7 @@ public class JavacordWrapper extends LibraryWrapper { }else builder.setSubCommand(TypeFactory.annotation(SubCommand.class, Map.of("name", options.getFirst().getName()))); } catch (AnnotationFormatException e) { - e.printStackTrace(); + logger.fatal(e); } return builder.build();