public abstract class Menu
extends java.lang.Object
EventWaiter
into a "action, reaction" menu that waits on forms of user input such as reactions,
or key-phrases.
Classes extending this are able to take a provided Message
or MessageChannel
and display a visualized "Menu"
as or in it.
The JDA-Utilities default implementations of this superclass typically handle input through
the assistance of things such as reactions
,
but the actual implementation is only limited to the events provided by Discord and handled through JDA.
For custom implementations, readability of creating and integrating may be improved
by the implementation of a companion builder may be helpful (see the documentation on
Menu.Builder
for more info).
EventWaiter
,
Menu.Builder
embeds
,
there is no bias or advantage of implementing a custom Menu as a message
without an embed.Modifier and Type | Class and Description |
---|---|
static class |
Menu.Builder<T extends Menu.Builder<T,V>,V extends Menu>
An extendable frame for a chain-method builder that constructs a specified type of
Menu . |
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<net.dv8tion.jda.core.entities.Role> |
roles |
protected long |
timeout |
protected java.util.concurrent.TimeUnit |
unit |
protected java.util.Set<net.dv8tion.jda.core.entities.User> |
users |
protected EventWaiter |
waiter |
Modifier | Constructor and Description |
---|---|
protected |
Menu(EventWaiter waiter,
java.util.Set<net.dv8tion.jda.core.entities.User> users,
java.util.Set<net.dv8tion.jda.core.entities.Role> roles,
long timeout,
java.util.concurrent.TimeUnit unit) |
Modifier and Type | Method and Description |
---|---|
abstract void |
display(net.dv8tion.jda.core.entities.Message message)
Displays this Menu as a designated
Message . |
abstract void |
display(net.dv8tion.jda.core.entities.MessageChannel channel)
Displays this Menu in a
MessageChannel . |
protected boolean |
isValidUser(net.dv8tion.jda.core.entities.User user)
Checks to see if the provided
User
is valid to interact with this Menu. |
protected boolean |
isValidUser(net.dv8tion.jda.core.entities.User user,
net.dv8tion.jda.core.entities.Guild guild)
Checks to see if the provided
User
is valid to interact with this Menu. |
protected final EventWaiter waiter
protected java.util.Set<net.dv8tion.jda.core.entities.User> users
protected java.util.Set<net.dv8tion.jda.core.entities.Role> roles
protected final long timeout
protected final java.util.concurrent.TimeUnit unit
protected Menu(EventWaiter waiter, java.util.Set<net.dv8tion.jda.core.entities.User> users, java.util.Set<net.dv8tion.jda.core.entities.Role> roles, long timeout, java.util.concurrent.TimeUnit unit)
public abstract void display(net.dv8tion.jda.core.entities.MessageChannel channel)
MessageChannel
.channel
- The MessageChannel to display this Menu inpublic abstract void display(net.dv8tion.jda.core.entities.Message message)
Message
.
User
will prevent the
Menu from being displayed!message
- The Message to display this Menu asprotected boolean isValidUser(net.dv8tion.jda.core.entities.User user)
User
is valid to interact with this Menu.
This is a shortcut for isValidUser(User, Guild)
where the Guild
is null
.
user
- The User to validate.true
if the User is valid, false
otherwise.isValidUser(User, Guild)
protected boolean isValidUser(net.dv8tion.jda.core.entities.User user, @Nullable net.dv8tion.jda.core.entities.Guild guild)
User
is valid to interact with this Menu.For a User to be considered "valid" to use a Menu, the following logic (in order) is applied:
false
immediately.true
.true
.null
, or if the User is not a member on the Guild, this
will return false
.user
- The User to validate.guild
- The Guild to validate the User on.true
if the User is valid, false
otherwise.