From dadbcd94290daa391bbc2b1a79d81ed073122de2 Mon Sep 17 00:00:00 2001 From: Aleksandar Damjanovic Date: Sun, 28 Apr 2024 21:30:30 +0200 Subject: [PATCH] return completablefuture chain on register --- README.md | 2 +- pom.xml | 2 +- .../java/com/github/zrdj/javachord/Javachord.java | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a987d72..50ac36c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Release artifact com.github.zrdj javachord - 3.8.0.6 + 3.8.0.7 ``` diff --git a/pom.xml b/pom.xml index 8400846..ff12a65 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.zrdj javachord - 3.8.0.6 + 3.8.0.7 11 diff --git a/src/main/java/com/github/zrdj/javachord/Javachord.java b/src/main/java/com/github/zrdj/javachord/Javachord.java index fedf689..9eabdc1 100644 --- a/src/main/java/com/github/zrdj/javachord/Javachord.java +++ b/src/main/java/com/github/zrdj/javachord/Javachord.java @@ -26,7 +26,6 @@ import org.javacord.api.entity.permission.Role; import org.javacord.api.entity.server.Server; import org.javacord.api.entity.user.User; -import org.javacord.api.interaction.ButtonInteraction; import org.javacord.api.interaction.MessageComponentInteraction; import org.javacord.api.interaction.SlashCommandOptionType; import org.javacord.api.listener.GloballyAttachableListener; @@ -34,6 +33,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -52,18 +53,18 @@ public void addCommand(final ApplicationCommand command) { public void addListener(final GloballyAttachableListener listener) { _listeners.add(listener); } - public void register(final DiscordApi discordApi) { + public CompletableFuture> register(final DiscordApi discordApi) { discordInstance = discordApi; var commandSet = _commands.stream().map(ApplicationCommand::toSlashCommand).collect(Collectors.toSet()); - discordApi.bulkOverwriteGlobalApplicationCommands(commandSet); _listeners.forEach(discordApi::addListener); + return discordApi.bulkOverwriteGlobalApplicationCommands(commandSet); } - public void register(final DiscordApi discordApi, final Server server) { + public CompletableFuture> register(final DiscordApi discordApi, final Server server) { discordInstance = discordApi; serverInstance = Optional.of(server); var commandSet = _commands.stream().map(ApplicationCommand::toSlashCommand).collect(Collectors.toSet()); - discordApi.bulkOverwriteServerApplicationCommands(server, commandSet); _listeners.forEach(discordApi::addListener); + return discordApi.bulkOverwriteServerApplicationCommands(server, commandSet); } }