add correct null handling for api objects

This commit is contained in:
tueem 2025-02-19 13:56:45 +01:00
parent 5d8f737481
commit 92704ca230
Signed by: tueem
GPG Key ID: 65C8667EC17A88FB
2 changed files with 6 additions and 1 deletions

View File

@ -57,6 +57,8 @@ public class Discord4JWrapper extends LibraryWrapper {
if (api != null)
api.on(InteractionCreateEvent.class)
.subscribe(event -> handleInteraction(event));
else
logger.warn("GatewayDiscordClient was null so no Events were subscribed to.");
logger.info("Discord4J wrapper loaded!");
}

View File

@ -44,7 +44,10 @@ public class JavacordWrapper extends LibraryWrapper {
public JavacordWrapper(DiscordApi api) {
this.api = api;
this.contextObjectProvider = new JavacordContextObjectProvider();
api.addInteractionCreateListener((e) -> handleInteraction(e.getInteraction()));
if (api != null)
api.addInteractionCreateListener((e) -> handleInteraction(e.getInteraction()));
else
logger.warn("DiscordApi was null so no Events were subscribed to.");
logger.info("Javacord wrapper loaded!");
}