Search in sources :

Example 1 with SelectOption

use of net.dv8tion.jda.api.interactions.components.selections.SelectOption in project Ree6 by Ree6-Applications.

the class Setup method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR)) {
        EmbedBuilder embedBuilder = new EmbedBuilder().setTitle("Setup Menu").setFooter(commandEvent.getGuild().getName() + " - " + Data.ADVERTISEMENT, commandEvent.getGuild().getIconUrl()).setColor(Color.cyan).setDescription("Which configuration do you want to check out?");
        List<SelectOption> optionList = new ArrayList<>();
        optionList.add(SelectOption.of("Audit-Logging", "log"));
        optionList.add(SelectOption.of("Welcome-channel", "welcome"));
        optionList.add(SelectOption.of("News-channel", "news"));
        optionList.add(SelectOption.of("Mute role", "mute"));
        optionList.add(SelectOption.of("Autorole", "autrorole"));
        SelectMenu selectMenu = new SelectMenuImpl("setupActionMenu", "Select a configuration Step!", 1, 1, false, optionList);
        if (commandEvent.isSlashCommand()) {
            commandEvent.getInteractionHook().sendMessageEmbeds(embedBuilder.build()).addActionRow(selectMenu).queue();
        } else {
            commandEvent.getTextChannel().sendMessageEmbeds(embedBuilder.build()).setActionRows(ActionRow.of(selectMenu)).queue();
        }
    } else {
        sendMessage("You dont have the Permission for this Command!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
    }
    deleteMessage(commandEvent.getMessage(), commandEvent.getInteractionHook());
}
Also used : SelectMenu(net.dv8tion.jda.api.interactions.components.selections.SelectMenu) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) SelectOption(net.dv8tion.jda.api.interactions.components.selections.SelectOption) ArrayList(java.util.ArrayList) SelectMenuImpl(net.dv8tion.jda.internal.interactions.component.SelectMenuImpl)

Example 2 with SelectOption

use of net.dv8tion.jda.api.interactions.components.selections.SelectOption in project BotCommands by freya022.

the class BasicInteractiveMenu method buildSelectMenu.

@NotNull
private SelectMenu buildSelectMenu() {
    final LambdaSelectionMenuBuilder builder = Components.selectionMenu(this::handleSelection).oneUse().setConstraints(constraints);
    final List<SelectOption> options = builder.getOptions();
    for (int i = 0, itemsSize = items.size(); i < itemsSize; i++) {
        InteractiveMenuItem<T> item = items.get(i);
        SelectOption option = item.content().toSelectOption(String.valueOf(i));
        if (i == selectedItem)
            option = option.withDefault(true);
        options.add(option);
    }
    return builder.build();
}
Also used : SelectOption(net.dv8tion.jda.api.interactions.components.selections.SelectOption) LambdaSelectionMenuBuilder(com.freya02.botcommands.api.components.builder.LambdaSelectionMenuBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SelectOption (net.dv8tion.jda.api.interactions.components.selections.SelectOption)2 LambdaSelectionMenuBuilder (com.freya02.botcommands.api.components.builder.LambdaSelectionMenuBuilder)1 ArrayList (java.util.ArrayList)1 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)1 SelectMenu (net.dv8tion.jda.api.interactions.components.selections.SelectMenu)1 SelectMenuImpl (net.dv8tion.jda.internal.interactions.component.SelectMenuImpl)1 NotNull (org.jetbrains.annotations.NotNull)1