Search in sources :

Example 1 with InternalArgument

use of dev.triumphteam.cmd.core.argument.InternalArgument in project triumph-cmds by TriumphTeam.

the class SlashSubCommand method getJdaOptions.

public List<OptionData> getJdaOptions() {
    final List<OptionData> options = new ArrayList<>();
    final List<InternalArgument<S, ?>> internalArguments = getArguments();
    for (int i = 0; i < internalArguments.size(); i++) {
        final InternalArgument<S, ?> internalArgument = internalArguments.get(i);
        final OptionData option = new OptionData(JdaOptionUtil.fromType(internalArgument.getType()), internalArgument.getName(), internalArgument.getDescription(), !internalArgument.isOptional());
        options.add(option);
        final Choice suggestion = getChoice(i);
        if (suggestion instanceof EmptyChoice)
            continue;
        option.addChoices(suggestion.getChoices().stream().map(it -> new Command.Choice(it, it)).limit(25).collect(Collectors.toList()));
    }
    return options;
}
Also used : List(java.util.List) EmptyChoice(dev.triumphteam.cmd.slash.choices.EmptyChoice) AbstractSubCommand(dev.triumphteam.cmd.core.AbstractSubCommand) ExecutionProvider(dev.triumphteam.cmd.core.execution.ExecutionProvider) OptionData(net.dv8tion.jda.api.interactions.commands.build.OptionData) Choice(dev.triumphteam.cmd.slash.choices.Choice) JdaOptionUtil(dev.triumphteam.cmd.slash.util.JdaOptionUtil) InternalArgument(dev.triumphteam.cmd.core.argument.InternalArgument) NotNull(org.jetbrains.annotations.NotNull) Command(net.dv8tion.jda.api.interactions.commands.Command) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) EmptyChoice(dev.triumphteam.cmd.slash.choices.EmptyChoice) Choice(dev.triumphteam.cmd.slash.choices.Choice) OptionData(net.dv8tion.jda.api.interactions.commands.build.OptionData) InternalArgument(dev.triumphteam.cmd.core.argument.InternalArgument) ArrayList(java.util.ArrayList) EmptyChoice(dev.triumphteam.cmd.slash.choices.EmptyChoice)

Aggregations

AbstractSubCommand (dev.triumphteam.cmd.core.AbstractSubCommand)1 InternalArgument (dev.triumphteam.cmd.core.argument.InternalArgument)1 ExecutionProvider (dev.triumphteam.cmd.core.execution.ExecutionProvider)1 Choice (dev.triumphteam.cmd.slash.choices.Choice)1 EmptyChoice (dev.triumphteam.cmd.slash.choices.EmptyChoice)1 JdaOptionUtil (dev.triumphteam.cmd.slash.util.JdaOptionUtil)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Command (net.dv8tion.jda.api.interactions.commands.Command)1 OptionData (net.dv8tion.jda.api.interactions.commands.build.OptionData)1 NotNull (org.jetbrains.annotations.NotNull)1