Module ultimategdbot.api
Class MessageMenuInteraction
- java.lang.Object
-
- com.github.alex1304.ultimategdbot.api.command.menu.MessageMenuInteraction
-
public final class MessageMenuInteraction extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeMenu()
Closes the menu.<T> T
get(String varName)
Gets a variable in the context of this interaction.ArgumentList
getArgs()
discord4j.core.event.domain.message.MessageCreateEvent
getEvent()
FlagSet
getFlags()
discord4j.core.object.entity.Message
getMenuMessage()
Gets the menu message prompting the user for interaction.Translator
getTranslator()
Gets the translator associated to the context the interactive menu is run.<T> void
set(String varName, T value)
Sets a variable in the context of this interaction to the given value.<T> T
update(String varName, UnaryOperator<T> valueUpdater)
Updates a variable in the context of this interaction.<T> T
update(String varName, UnaryOperator<T> valueUpdater, T defaultValue)
Updates a variable in the context of this interaction.
-
-
-
Method Detail
-
getEvent
public discord4j.core.event.domain.message.MessageCreateEvent getEvent()
-
getArgs
public ArgumentList getArgs()
-
getFlags
public FlagSet getFlags()
-
getTranslator
public Translator getTranslator()
Gets the translator associated to the context the interactive menu is run.- Returns:
- the translator
-
update
public <T> T update(String varName, UnaryOperator<T> valueUpdater)
Updates a variable in the context of this interaction.- Type Parameters:
T
- the type of value- Parameters:
varName
- the variable namevalueUpdater
- the function that updates the value. The function may return null to signal that the variable should be unset- Returns:
- the value after update
- Throws:
NoSuchElementException
- if attempt to update a non-existing variableClassCastException
- if the value isn't of type T
-
update
public <T> T update(String varName, UnaryOperator<T> valueUpdater, T defaultValue)
Updates a variable in the context of this interaction.- Type Parameters:
T
- the type of value- Parameters:
varName
- the variable namevalueUpdater
- the function that updates the value. The function may returnnull
to signal that the variable should be unsetdefaultValue
- the value to take if the variable is not set- Returns:
- the value after update
- Throws:
ClassCastException
- if the value isn't of type T
-
set
public <T> void set(String varName, @Nullable T value)
Sets a variable in the context of this interaction to the given value.- Type Parameters:
T
- the type of value- Parameters:
varName
- the variable namevalue
- the new value, ornull
to unset
-
get
public <T> T get(String varName)
Gets a variable in the context of this interaction.- Type Parameters:
T
- the expected type of the value- Parameters:
varName
- teh variable name- Returns:
- the value associated to the variable
- Throws:
NoSuchElementException
- if no variable for the given name is setClassCastException
- if the value is not of typeT
-
getMenuMessage
public discord4j.core.object.entity.Message getMenuMessage()
Gets the menu message prompting the user for interaction.- Returns:
- the Discord message of the menu
-
closeMenu
public void closeMenu()
Closes the menu. No more interactions will be registered once this call returns.
-
-