add register impl

This commit is contained in:
tueem 2024-10-29 23:20:19 +01:00
parent 22f9810f7b
commit b0abb423d3
No known key found for this signature in database
GPG Key ID: 819A0F7C36B9CF07

@ -3,8 +3,10 @@ package net.tomatentum.marinare.wrapper.javacord;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.javacord.api.DiscordApi; import org.javacord.api.DiscordApi;
import org.javacord.api.interaction.SlashCommandBuilder; import org.javacord.api.interaction.SlashCommandBuilder;
@ -29,8 +31,23 @@ public class JavacordWrapper extends LibraryWrapper {
@Override @Override
public void registerSlashCommands(SlashCommandDefinition[] defs) { public void registerSlashCommands(SlashCommandDefinition[] defs) {
// TODO Auto-generated method stub HashMap<Long, Set<SlashCommandBuilder>> serverCommands = new HashMap<>();
throw new UnsupportedOperationException("Unimplemented method 'registerSlashCommands'"); Set<SlashCommandBuilder> globalCommands = new HashSet<>();
for (SlashCommandDefinition slashCommandDefinition : defs) {
SlashCommandBuilder builder = convertSlashCommand(slashCommandDefinition);
if (slashCommandDefinition.getFullSlashCommand().serverIds().length > 0) {
for (long serverId : slashCommandDefinition.getFullSlashCommand().serverIds()) {
serverCommands.putIfAbsent(serverId, new HashSet<>());
serverCommands.get(serverId).add(builder);
}
}else
globalCommands.add(builder);
}
for (long serverId : serverCommands.keySet()) {
api.bulkOverwriteServerApplicationCommands(serverId, serverCommands.get(serverId));
}
api.bulkOverwriteGlobalApplicationCommands(globalCommands);
} }
@Override @Override