Skip to content

Commit

Permalink
GH-483 Respect JDA choices limit. (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rollczi authored Nov 11, 2024
1 parent b98670c commit db82fd4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<User, LiteJDASettings> {
Expand Down Expand Up @@ -138,7 +139,8 @@ public void onCommandAutoCompleteInteraction(CommandAutoCompleteInteractionEvent
List<Command.Choice> 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();
Expand Down

0 comments on commit db82fd4

Please sign in to comment.