Package com.jagrosh.jdautilities.menu
Class OrderedMenu.Builder
java.lang.Object
com.jagrosh.jdautilities.menu.Menu.Builder<OrderedMenu.Builder,OrderedMenu>
com.jagrosh.jdautilities.menu.OrderedMenu.Builder
- Enclosing class:
OrderedMenu
The
Menu.Builder for
an OrderedMenu.- Author:
- John Grosh
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a single String choice.addChoices(String... choices) Adds the String choices.allowTextInput(boolean allow) Iftrue,Users can type the number or letter of the input to make their selection, in addition to the reaction option.build()Builds theOrderedMenuwith this Builder.Clears all previously set choices.Sets theConsumerto perform if theOrderedMenuis cancelled.setChoices(String... choices) Sets the String choices.Sets theColorof theMessageEmbed.setDescription(String description) Sets the description to be placed in anMessageEmbed.setSelection(BiConsumer<net.dv8tion.jda.api.entities.Message, Integer> selection) Sets theBiConsumeraction to perform upon selecting a option.Sets the text of theMessageto be displayed when theOrderedMenuis built.useCancelButton(boolean use) Iftrue, adds a cancel button that performs the timeout action when selected.Sets the builder to build anOrderedMenuusing letters for ordering and reactions (IE: A, B, C, etc.).Sets the builder to build anOrderedMenuusing numbers for ordering and reactions (IE: 1, 2, 3, etc.).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 theOrderedMenuwith this Builder.- Specified by:
buildin classMenu.Builder<OrderedMenu.Builder,OrderedMenu> - Returns:
- The OrderedMenu built from this Builder.
- Throws:
IllegalArgumentException- If one of the following is violated:- No
EventWaiterwas set. - No choices were set.
- More than ten choices were set.
- No action
Consumerwas set. - Neither text nor description were set.
- No
-
setColor
Sets theColorof theMessageEmbed.- Parameters:
color- The Color of the MessageEmbed- Returns:
- This builder
-
useLetters
Sets the builder to build anOrderedMenuusing letters for ordering and reactions (IE: A, B, C, etc.).
As a note - by default the builder will use numbers not letters.- Returns:
- This builder
-
useNumbers
Sets the builder to build anOrderedMenuusing numbers for ordering and reactions (IE: 1, 2, 3, etc.).- Returns:
- This builder
-
allowTextInput
Iftrue,Users can type the number or letter of the input to make their selection, in addition to the reaction option.- Parameters:
allow-trueif raw text input is allowed,falseif it is not- Returns:
- This builder
-
useCancelButton
Iftrue, adds a cancel button that performs the timeout action when selected.- Parameters:
use-trueif the cancel button should be shown,falseif it should not- Returns:
- This builder
-
setText
Sets the text of theMessageto be displayed when theOrderedMenuis built.This is displayed directly above the embed.
- Parameters:
text- The Message content to be displayed above the embed when the OrderedMenu is built- Returns:
- This builder
-
setDescription
Sets the description to be placed in anMessageEmbed.
If this isnull, no MessageEmbed will be displayed- Parameters:
description- The content of the MessageEmbed's description- Returns:
- This builder
-
setSelection
public OrderedMenu.Builder setSelection(BiConsumer<net.dv8tion.jda.api.entities.Message, Integer> selection) Sets theBiConsumeraction to perform upon selecting a option.- Parameters:
selection- The BiConsumer action to perform upon selecting a button- Returns:
- This builder
-
setCancel
Sets theConsumerto perform if theOrderedMenuis cancelled.- Parameters:
cancel- The Consumer action to perform if the ButtonMenu is cancelled- Returns:
- This builder
-
addChoice
Adds a single String choice.- Parameters:
choice- The String choice to add- Returns:
- This builder
-
addChoices
Adds the String choices.
These correspond to the button in order of addition.- Parameters:
choices- The String choices to add- Returns:
- This builder
-
setChoices
Sets the String choices.
These correspond to the button in the order they are set.- Parameters:
choices- The String choices to set- Returns:
- This builder
-
clearChoices
Clears all previously set choices.- Returns:
- This builder
-