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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal TaddRoles(net.dv8tion.jda.api.entities.Role... roles) AddsRoles that are allowed to use theMenuthat will be built.final TaddUsers(net.dv8tion.jda.api.entities.User... users) AddsUsers that are allowed to use theMenuthat will be built.abstract Vbuild()Builds theMenucorresponding to thisMenu.Builder.final TsetEventWaiter(EventWaiter waiter) Sets theEventWaiterthat will doMenuoperations.final TsetRoles(net.dv8tion.jda.api.entities.Role... roles) SetsRoles that are allowed to use theMenuthat will be built.final TsetTimeout(long timeout, TimeUnit unit) Sets the timeout that theMenushould stay available.final TsetUsers(net.dv8tion.jda.api.entities.User... users) SetsUsers that are allowed to use theMenuthat will be built.
-
Field Details
-
waiter
-
users
-
roles
-
timeout
protected long timeout -
unit
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds theMenucorresponding 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 theEventWaiterthat will doMenuoperations.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
AddsUsers that are allowed to use theMenuthat will be built.- Parameters:
users- The Users allowed to use the Menu- Returns:
- This builder
-
setUsers
SetsUsers that are allowed to use theMenuthat 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
AddsRoles that are allowed to use theMenuthat will be built.- Parameters:
roles- The Roles allowed to use the Menu- Returns:
- This builder
-
setRoles
SetsRoles that are allowed to use theMenuthat 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 theMenushould stay available.After this has expired, the a final action in the form of a
Runnablemay execute.- Parameters:
timeout- The amount of time for the Menu to stay availableunit- TheTimeUnitfor the timeout- Returns:
- This builder
-