From ef055ee8ae11d3d5d9033158cb1144a2e2fd2d42 Mon Sep 17 00:00:00 2001 From: Rollczi Date: Mon, 11 Nov 2024 13:34:00 +0100 Subject: [PATCH] Respect JDA choices limit. --- .../src/dev/rollczi/litecommands/jda/JDAPlatform.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litecommands-jda/src/dev/rollczi/litecommands/jda/JDAPlatform.java b/litecommands-jda/src/dev/rollczi/litecommands/jda/JDAPlatform.java index 984e481b..4eabf3d5 100644 --- a/litecommands-jda/src/dev/rollczi/litecommands/jda/JDAPlatform.java +++ b/litecommands-jda/src/dev/rollczi/litecommands/jda/JDAPlatform.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.dv8tion.jda.api.interactions.commands.build.OptionData; import org.jetbrains.annotations.Nullable; class JDAPlatform extends AbstractPlatform { @@ -138,7 +139,8 @@ public void onCommandAutoCompleteInteraction(CommandAutoCompleteInteractionEvent List choiceList = result.getSuggestions().stream() .filter(suggestion -> !suggestion.multilevel().isEmpty()) .map(suggestion -> choice(event.getFocusedOption().getType(), suggestion)) - .filter(Objects::nonNull) + .filter(choice -> Objects.nonNull(choice)) + .limit(OptionData.MAX_CHOICES) .collect(Collectors.toList()); event.replyChoices(choiceList).queue();