Skip to content

Commit

Permalink
return completablefuture chain on register
Browse files Browse the repository at this point in the history
  • Loading branch information
codejanovic committed Apr 28, 2024
1 parent c2383cc commit dadbcd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Release artifact
<dependency>
<groupId>com.github.zrdj</groupId>
<artifactId>javachord</artifactId>
<version>3.8.0.6</version>
<version>3.8.0.7</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.zrdj</groupId>
<artifactId>javachord</artifactId>
<version>3.8.0.6</version>
<version>3.8.0.7</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/github/zrdj/javachord/Javachord.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
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;

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;
Expand All @@ -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<Set<org.javacord.api.interaction.ApplicationCommand>> 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<Set<org.javacord.api.interaction.ApplicationCommand>> 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);
}
}

Expand Down

0 comments on commit dadbcd9

Please sign in to comment.