improve wrapper and general structure #16

Merged
tueem merged 23 commits from improve/structure into dev 2025-03-17 08:26:44 +00:00
Showing only changes of commit 8f14b0feb9 - Show all commits

View File

@ -51,21 +51,16 @@ public class SlashCommandDefinition {
subCommandGroupMap.put(x.name(), x); subCommandGroupMap.put(x.name(), x);
}); });
return subCommandGroupMap.values().toArray(new SubCommandGroup[0]); return subCommandGroupMap.values().toArray(SubCommandGroup[]::new);
} }
public SubCommand[] getSubCommands(String groupName) { public SubCommand[] getSubCommands() {
List<SubCommand> subCommands; List<SubCommand> subCommands;
if (groupName == null) subCommands = Arrays.stream(getExecutableDefinitons())
subCommands = Arrays.stream(getExecutableDefinitons()) .filter((x) -> x.subCommandGroup() == null && x.subCommand() != null)
.filter((x) -> x.subCommandGroup() == null && x.subCommand() != null) .map((x) -> x.subCommand())
.map((x) -> x.subCommand()) .toList();
.toList();
else
subCommands = Arrays.stream(getExecutableDefinitons())
.filter((x) -> x.subCommandGroup().name().equals(groupName) && x.subCommand() != null)
.map((x) -> x.subCommand())
.toList();
HashMap<String, SubCommand> subCommandMap = new HashMap<>(); HashMap<String, SubCommand> subCommandMap = new HashMap<>();
subCommands.forEach((x) -> { subCommands.forEach((x) -> {
@ -74,18 +69,24 @@ public class SlashCommandDefinition {
subCommandMap.put(x.name(), x); subCommandMap.put(x.name(), x);
}); });
return subCommandMap.values().toArray(new SubCommand[0]); return subCommandMap.values().toArray(SubCommand[]::new);
} }
public SlashCommand getFullSlashCommand() { public SubCommand[] getSubCommands(String groupName) {
if (isRootCommand()) List<SubCommand> subCommands;
return getSlashCommand(); subCommands = Arrays.stream(getExecutableDefinitons())
for (ExecutableSlashCommandDefinition executableSlashCommandDefinition : executableDefinitons) { .filter((x) -> x.subCommandGroup().name().equals(groupName) && x.subCommand() != null)
if (executableSlashCommandDefinition.options().length > 0) .map((x) -> x.subCommand())
return executableSlashCommandDefinition.applicationCommand(); .toList();
}
return null; HashMap<String, SubCommand> subCommandMap = new HashMap<>();
subCommands.forEach((x) -> {
SubCommand current = subCommandMap.get(x.name());
if (current == null || (current.description().isBlank() && !x.description().isBlank()))
subCommandMap.put(x.name(), x);
});
return subCommandMap.values().toArray(SubCommand[]::new);
} }
public SlashCommand getSlashCommand() { public SlashCommand getSlashCommand() {