fix(wrapper): add condition for CommandRegisterer if api is null

This commit is contained in:
Tueem 2025-03-16 23:35:39 +01:00
parent bae077654e
commit bce4ce7812
Signed by: tueem
GPG Key ID: F2CE0513D231AD7A
2 changed files with 6 additions and 6 deletions

View File

@ -41,12 +41,12 @@ public class Discord4JWrapper extends LibraryWrapper {
public Discord4JWrapper(GatewayDiscordClient api) {
this.contextObjectProvider = new Discord4JContextObjectProvider();
var converter = CommandConverter.of(new Discord4JConverterSpec());
this.commandRegisterer = CommandRegisterer.of(new Discord4JRegistererStrategy(api), converter);
if (api != null)
if (api != null) {
this.commandRegisterer = CommandRegisterer.of(new Discord4JRegistererStrategy(api), converter);
api.on(InteractionCreateEvent.class)
.subscribe(event -> handleInteraction(event));
else
}else
logger.warn("GatewayDiscordClient was null so no Events were subscribed to.");
logger.info("Discord4J wrapper loaded!");

View File

@ -24,11 +24,11 @@ public class JavacordWrapper extends LibraryWrapper {
public JavacordWrapper(DiscordApi api) {
this.contextObjectProvider = new JavacordContextObjectProvider();
var converter = CommandConverter.of(new JavacordConverterSpec());
this.commandRegisterer = CommandRegisterer.of(new JavacordRegistererStrategy(api), converter);
if (api != null)
if (api != null) {
this.commandRegisterer = CommandRegisterer.of(new JavacordRegistererStrategy(api), converter);
api.addInteractionCreateListener((e) -> handleInteraction(e.getInteraction()));
else
}else
logger.warn("DiscordApi was null so no Events were subscribed to.");
logger.info("Javacord wrapper loaded!");
}