Package com.jagrosh.jdautilities.menu
Class SelectionDialog.Builder
java.lang.Object
com.jagrosh.jdautilities.menu.Menu.Builder<SelectionDialog.Builder,SelectionDialog>
com.jagrosh.jdautilities.menu.SelectionDialog.Builder
- Enclosing class:
- SelectionDialog
public static class SelectionDialog.Builder
extends Menu.Builder<SelectionDialog.Builder,SelectionDialog>
The
Menu.Builder for
a SelectuibDialog.- Author:
- John Grosh
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddChoices(String... choices) Adds String choices to be shown as selections.build()Builds theSelectionDialogwith this Builder.Clears the choices to be shown.setCanceled(Consumer<net.dv8tion.jda.api.entities.Message> cancel) Sets aConsumeraction to take if the menu is cancelled, either via the cancel button being used, or if the SelectionDialog times out.setChoices(String... choices) Sets the String choices to be shown as selections.Sets theColorof theMessageEmbed.setDefaultEnds(String left, String right) Sets the text to use on either side of all unselected items.setSelectedEnds(String left, String right) Sets the text to use on either end of the selected item.setSelectionConsumer(BiConsumer<net.dv8tion.jda.api.entities.Message, Integer> selection) Sets aBiConsumeraction to perform once a selection is made.Sets the text of theMessageto be displayed when theSelectionDialogis built.Sets the text of theMessageto be displayed relative to the current selection number as determined by the providedFunction.useLooping(boolean loop) Sets if moving up when at the top selection jumps to the bottom, and visa-versa.useSingleSelectionMode(boolean singleSelectionMode) Sets if the Menu should exit when a selection was made.Methods inherited from class com.jagrosh.jdautilities.menu.Menu.Builder
addRoles, addUsers, setEventWaiter, setRoles, setTimeout, setUsers
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds theSelectionDialogwith this Builder.- Specified by:
buildin classMenu.Builder<SelectionDialog.Builder,SelectionDialog> - Returns:
- The OrderedMenu built from this Builder.
- Throws:
IllegalArgumentException- If one of the following is violated:- No
EventWaiterwas set. - No choices were set.
- No action
Consumerwas set.
- No
-
setColor
Sets theColorof theMessageEmbed.- Parameters:
color- The Color of the MessageEmbed- Returns:
- This builder
-
setColor
Sets theColorof theMessageEmbed, relative to the current selection number as determined by the providedFunction.
As the selection changes, the Function will re-process the current selection number, allowing for the color of the embed to change depending on the selection number.- Parameters:
color- A Function that uses current selection number to get a Color for the MessageEmbed- Returns:
- This builder
-
setText
Sets the text of theMessageto be displayed when theSelectionDialogis built.This is displayed directly above the embed.
- Parameters:
text- The Message content to be displayed above the embed when the SelectionDialog is built- Returns:
- This builder
-
setText
Sets the text of theMessageto be displayed relative to the current selection number as determined by the providedFunction.
As the selection changes, the Function will re-process the current selection number, allowing for the displayed text of the Message to change depending on the selection number.- Parameters:
text- A Function that uses current selection number to get a text for the Message- Returns:
- This builder
-
setSelectedEnds
Sets the text to use on either end of the selected item.
Usage is primarily to mark which item is currently selected.- Parameters:
left- The left selection endright- The right selection end- Returns:
- This builder
-
setDefaultEnds
Sets the text to use on either side of all unselected items. This will not be applied to the selected item.
Usage is primarily to mark which items are not currently selected.- Parameters:
left- The left non-selection endright- The right non-selection end- Returns:
- This builder
-
useLooping
Sets if moving up when at the top selection jumps to the bottom, and visa-versa.- Parameters:
loop-trueif pressing up while at the top selection should loop to the bottom,falseif it should not- Returns:
- This builder
-
useSingleSelectionMode
Sets if the Menu should exit when a selection was made. By default, this is false and the menu continues showing choices even after a selection was made.- Parameters:
singleSelectionMode-trueif the menu should exit after the first selection being made- Returns:
- This builder
-
setSelectionConsumer
public SelectionDialog.Builder setSelectionConsumer(BiConsumer<net.dv8tion.jda.api.entities.Message, Integer> selection) Sets aBiConsumeraction to perform once a selection is made.
TheMessageprovided is the one used to display the menu and theIntegeris that of the selection made by the user, and selections are in order of addition, 1 being the first String choice.- Parameters:
selection- A Consumer for the selection. This is one-based indexing.- Returns:
- This builder
-
setCanceled
Sets aConsumeraction to take if the menu is cancelled, either via the cancel button being used, or if the SelectionDialog times out.- Parameters:
cancel- The action to take when the SelectionDialog is cancelled- Returns:
- This builder
-
clearChoices
Clears the choices to be shown.- Returns:
- This builder
-
setChoices
Sets the String choices to be shown as selections.- Parameters:
choices- The String choices to show- Returns:
- the builder
-
addChoices
Adds String choices to be shown as selections.- Parameters:
choices- The String choices to add- Returns:
- This builder
-