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 as embeds, there is no bias or advantage of implementing a custom Menu as a message without an embed.
  • Field Details

    • waiter

      protected EventWaiter waiter
    • users

      protected Set<net.dv8tion.jda.api.entities.User> users
    • roles

      protected Set<net.dv8tion.jda.api.entities.Role> roles
    • timeout

      protected long timeout
    • unit

      protected TimeUnit unit
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public abstract V build()
      Builds the Menu corresponding to this Menu.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

      public final T setEventWaiter(EventWaiter waiter)
      Sets the EventWaiter that will do Menu 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

      public final T addUsers(net.dv8tion.jda.api.entities.User... users)
      Adds Users that are allowed to use the Menu that will be built.
      Parameters:
      users - The Users allowed to use the Menu
      Returns:
      This builder
    • setUsers

      public final T setUsers(net.dv8tion.jda.api.entities.User... users)
      Sets Users that are allowed to use the Menu 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

      public final T addRoles(net.dv8tion.jda.api.entities.Role... roles)
      Adds Roles that are allowed to use the Menu that will be built.
      Parameters:
      roles - The Roles allowed to use the Menu
      Returns:
      This builder
    • setRoles

      public final T setRoles(net.dv8tion.jda.api.entities.Role... roles)
      Sets Roles that are allowed to use the Menu 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

      public final T setTimeout(long timeout, TimeUnit unit)
      Sets the timeout that the Menu 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 available
      unit - The TimeUnit for the timeout
      Returns:
      This builder