Package com.jagrosh.jdautilities.menu
Class Menu.Builder<T extends Menu.Builder<T,V>,V extends Menu>
java.lang.Object
com.jagrosh.jdautilities.menu.Menu.Builder<T,V>
- Direct Known Subclasses:
ButtonEmbedPaginator.Builder
,ButtonMenu.Builder
,EmbedPaginator.Builder
,OrderedMenu.Builder
,Paginator.Builder
,SelectionDialog.Builder
,Slideshow.Builder
- Enclosing class:
Menu
public abstract static class Menu.Builder<T extends Menu.Builder<T,V>,V extends Menu>
extends Object
An extendable frame for a chain-method builder that constructs a specified type of
Menu
.
Conventionally, implementations of Menu should have a static nested class called
Builder
, which extends this superclass:
public class MyMenu extends Menu
{
// Menu Code
public static class Builder extends Menu.Builder<Builder, MyMenu>
{
// Builder Code
}
}
- Author:
- John Grosh
- Implementation Note:
- Before 2.0 this were a separate class known as
MenuBuilder
.
Note that while the standard JDA-Utilities implementations of this and Menu are all handled asembeds
, there is no bias or advantage of implementing a custom Menu as a message without an embed.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal T
addRoles
(net.dv8tion.jda.api.entities.Role... roles) AddsRole
s that are allowed to use theMenu
that will be built.final T
addUsers
(net.dv8tion.jda.api.entities.User... users) AddsUser
s that are allowed to use theMenu
that will be built.abstract V
build()
Builds theMenu
corresponding to thisMenu.Builder
.final T
setEventWaiter
(EventWaiter waiter) Sets theEventWaiter
that will doMenu
operations.final T
setRoles
(net.dv8tion.jda.api.entities.Role... roles) SetsRole
s that are allowed to use theMenu
that will be built.final T
setTimeout
(long timeout, TimeUnit unit) Sets the timeout that theMenu
should stay available.final T
setUsers
(net.dv8tion.jda.api.entities.User... users) SetsUser
s that are allowed to use theMenu
that will be built.
-
Field Details
-
waiter
-
users
-
roles
-
timeout
protected long timeout -
unit
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds theMenu
corresponding to thisMenu.Builder
.
After doing this, no modifications of the displayed Menu can be made.- Returns:
- The built Menu of corresponding type to this
Menu.Builder
.
-
setEventWaiter
Sets theEventWaiter
that will doMenu
operations.NOTE: All Menus will only work with an EventWaiter set!
Not setting an EventWaiter means the Menu will not work.- Parameters:
waiter
- The EventWaiter- Returns:
- This builder
-
addUsers
AddsUser
s that are allowed to use theMenu
that will be built.- Parameters:
users
- The Users allowed to use the Menu- Returns:
- This builder
-
setUsers
SetsUser
s that are allowed to use theMenu
that will be built.
This clears any Users already registered before adding the ones specified.- Parameters:
users
- The Users allowed to use the Menu- Returns:
- This builder
-
addRoles
AddsRole
s that are allowed to use theMenu
that will be built.- Parameters:
roles
- The Roles allowed to use the Menu- Returns:
- This builder
-
setRoles
SetsRole
s that are allowed to use theMenu
that will be built.
This clears any Roles already registered before adding the ones specified.- Parameters:
roles
- The Roles allowed to use the Menu- Returns:
- This builder
-
setTimeout
Sets the timeout that theMenu
should stay available.After this has expired, the a final action in the form of a
Runnable
may execute.- Parameters:
timeout
- The amount of time for the Menu to stay availableunit
- TheTimeUnit
for the timeout- Returns:
- This builder
-