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
-
Method Summary
Modifier and TypeMethodDescriptionAdds a single String choice.addChoices
(String... choices) Adds the String choices.allowTextInput
(boolean allow) Iftrue
,User
s can type the number or letter of the input to make their selection, in addition to the reaction option.build()
Builds theOrderedMenu
with this Builder.Clears all previously set choices.Sets theConsumer
to perform if theOrderedMenu
is cancelled.setChoices
(String... choices) Sets the String choices.Sets theColor
of theMessageEmbed
.setDescription
(String description) Sets the description to be placed in anMessageEmbed
.setSelection
(BiConsumer<net.dv8tion.jda.api.entities.Message, Integer> selection) Sets theBiConsumer
action to perform upon selecting a option.Sets the text of theMessage
to be displayed when theOrderedMenu
is built.useCancelButton
(boolean use) Iftrue
, adds a cancel button that performs the timeout action when selected.Sets the builder to build anOrderedMenu
using letters for ordering and reactions (IE: A, B, C, etc.).Sets the builder to build anOrderedMenu
using 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 theOrderedMenu
with this Builder.- Specified by:
build
in classMenu.Builder<OrderedMenu.Builder,
OrderedMenu> - Returns:
- The OrderedMenu built from this Builder.
- Throws:
IllegalArgumentException
- If one of the following is violated:- No
EventWaiter
was set. - No choices were set.
- More than ten choices were set.
- No action
Consumer
was set. - Neither text nor description were set.
- No
-
setColor
Sets theColor
of theMessageEmbed
.- Parameters:
color
- The Color of the MessageEmbed- Returns:
- This builder
-
useLetters
Sets the builder to build anOrderedMenu
using 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 anOrderedMenu
using numbers for ordering and reactions (IE: 1, 2, 3, etc.).- Returns:
- This builder
-
allowTextInput
Iftrue
,User
s can type the number or letter of the input to make their selection, in addition to the reaction option.- Parameters:
allow
-true
if raw text input is allowed,false
if it is not- Returns:
- This builder
-
useCancelButton
Iftrue
, adds a cancel button that performs the timeout action when selected.- Parameters:
use
-true
if the cancel button should be shown,false
if it should not- Returns:
- This builder
-
setText
Sets the text of theMessage
to be displayed when theOrderedMenu
is 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 theBiConsumer
action to perform upon selecting a option.- Parameters:
selection
- The BiConsumer action to perform upon selecting a button- Returns:
- This builder
-
setCancel
Sets theConsumer
to perform if theOrderedMenu
is 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
-