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
-
Method Summary
Modifier and TypeMethodDescriptionaddChoices
(String... choices) Adds String choices to be shown as selections.build()
Builds theSelectionDialog
with this Builder.Clears the choices to be shown.setCanceled
(Consumer<net.dv8tion.jda.api.entities.Message> cancel) Sets aConsumer
action 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 theColor
of 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 aBiConsumer
action to perform once a selection is made.Sets the text of theMessage
to be displayed when theSelectionDialog
is built.Sets the text of theMessage
to 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 theSelectionDialog
with this Builder.- Specified by:
build
in classMenu.Builder<SelectionDialog.Builder,
SelectionDialog> - Returns:
- The OrderedMenu built from this Builder.
- Throws:
IllegalArgumentException
- If one of the following is violated:- No
EventWaiter
was set. - No choices were set.
- No action
Consumer
was set.
- No
-
setColor
Sets theColor
of theMessageEmbed
.- Parameters:
color
- The Color of the MessageEmbed- Returns:
- This builder
-
setColor
Sets theColor
of 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 theMessage
to be displayed when theSelectionDialog
is 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 theMessage
to 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
-true
if pressing up while at the top selection should loop to the bottom,false
if 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
-true
if 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 aBiConsumer
action to perform once a selection is made.
TheMessage
provided is the one used to display the menu and theInteger
is 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 aConsumer
action 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
-