HidekoBot/src/main/java/wtf/beatrice/hidekobot/commands/completer/AvatarCommandCompleter.java

40 lines
1.3 KiB
Java
Raw Normal View History

2022-11-20 18:56:57 +01:00
package wtf.beatrice.hidekobot.commands.completer;
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.Command;
import org.jetbrains.annotations.NotNull;
2022-11-21 20:20:11 +01:00
import wtf.beatrice.hidekobot.Cache;
import wtf.beatrice.hidekobot.objects.commands.SlashArgumentsCompleterImpl;
import wtf.beatrice.hidekobot.objects.commands.SlashCommand;
2022-11-20 18:56:57 +01:00
import java.util.ArrayList;
import java.util.List;
public class AvatarCommandCompleter extends SlashArgumentsCompleterImpl
2022-11-20 18:56:57 +01:00
{
public AvatarCommandCompleter(SlashCommand parentCommand) {
super(parentCommand);
}
@Override
public void runCompletion(@NotNull CommandAutoCompleteInteractionEvent event) {
2022-11-20 18:56:57 +01:00
if(event.getFocusedOption().getName().equals("size"))
{
List<Command.Choice> options = new ArrayList<>();
2022-11-21 20:20:11 +01:00
for(int res : Cache.getSupportedAvatarResolutions())
2022-11-20 18:56:57 +01:00
{
String resString = String.valueOf(res);
String userInput = event.getFocusedOption().getValue();
if(resString.startsWith(userInput))
options.add(new Command.Choice(resString, res));
}
event.replyChoices(options).queue();
}
}
}