Skip to content

Commit 6051197

Browse files
Merge pull request #345 from danthe1st/fix-tag-autocomplete
fix /tag-view
2 parents 7426b94 + 665c175 commit 6051197

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/main/java/net/javadiscord/javabot/systems/staff_commands/tags/CustomTagManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,21 @@ public CustomTagManager(@NotNull JDA jda, @NotNull DataSource dataSource) {
6363
* Replies with all available custom tags.
6464
*
6565
* @param guild The current {@link Guild}.
66+
* @param text The text choices need to match
6667
* @return A {@link List} with all Option Choices.
6768
*/
68-
public static @NotNull List<Command.Choice> replyTags(@NotNull Guild guild) {
69+
public static @NotNull List<Command.Choice> replyTags(@NotNull Guild guild, String text) {
6970
List<Command.Choice> choices = new ArrayList<>(25);
7071
for (CustomTag command : LOADED_TAGS.get(guild.getIdLong())) {
71-
if (choices.size() < 26) {
72+
if (choices.size() < 26 && command.getName().toLowerCase().contains(text)) {
7273
choices.add(new Command.Choice(command.getName(), command.getName()));
7374
}
7475
}
7576
return choices;
7677
}
7778

7879
public static @NotNull AutoCompleteCallbackAction handleAutoComplete(@NotNull CommandAutoCompleteInteractionEvent event) {
79-
return event.replyChoices(AutoCompleteUtils.handleChoices(event, e -> replyTags(e.getGuild())));
80+
return event.replyChoices(AutoCompleteUtils.handleChoices(event, e -> replyTags(e.getGuild(), e.getFocusedOption().getValue().toLowerCase())));
8081
}
8182

8283
/**

src/main/java/net/javadiscord/javabot/systems/staff_commands/tags/commands/TagViewSubcommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public ReplyCallbackAction handleCustomTagsSubcommand(@NotNull SlashCommandInter
4040
if (tagOptional.isPresent()) {
4141
CustomTagManager.handleCustomTag(event, tagOptional.get()).queue();
4242
} else {
43-
Responses.error(event.getHook(), "Could not find Custom Tag with name `%s`.", nameMapping.getAsString());
43+
Responses.error(event.getHook(), "Could not find Custom Tag with name `%s`.", nameMapping.getAsString()).queue();
4444
}
4545
return event.deferReply(false);
4646
}

0 commit comments

Comments
 (0)