Package com.github.ygimenez.model.helper
Class ButtonizeHelper
java.lang.Object
com.github.ygimenez.model.helper.BaseHelper<ButtonizeHelper,Map<net.dv8tion.jda.api.entities.emoji.Emoji,ThrowingConsumer<ButtonWrapper>>>
com.github.ygimenez.model.helper.ButtonizeHelper
public class ButtonizeHelper
extends BaseHelper<ButtonizeHelper,Map<net.dv8tion.jda.api.entities.emoji.Emoji,ThrowingConsumer<ButtonWrapper>>>
Helper class for building buttonize events, safe for reuse.
-
Constructor Summary
ConstructorsConstructorDescriptionButtonizeHelper(boolean useButtons)Creates a new buttonize event helper with the default map implementation (LinkedHashMap).ButtonizeHelper(Map<net.dv8tion.jda.api.entities.emoji.Emoji,ThrowingConsumer<ButtonWrapper>> buttons, boolean useButtons)Creates a new buttonize event helper with the supplied map. -
Method Summary
Modifier and TypeMethodDescriptionaddAction(net.dv8tion.jda.api.entities.emoji.Emoji emoji, ThrowingConsumer<ButtonWrapper> action)Adds a new button to the map.<Out extends net.dv8tion.jda.api.utils.messages.MessageRequest<Out>>
List<net.dv8tion.jda.api.interactions.components.LayoutComponent>getComponents(Out action)Retrieves theListofComponents generated by this helper.Consumer<net.dv8tion.jda.api.entities.Message>Retrieves theConsumerthat'll be executed when the event ends.setOnFinalization(Consumer<net.dv8tion.jda.api.entities.Message> onFinalization)Defines an action to be executed when the event finishes, either by user action or timed finalization.booleanshouldUpdate(net.dv8tion.jda.api.entities.Message msg)Calculates whether theMessageneeds to have buttons applied onto or not.Methods inherited from class com.github.ygimenez.model.helper.BaseHelper
apply, canInteract, getContent, getTimeout, isCancellable, isUsingButtons, setCancellable, setCanInteract, setTimeout
-
Constructor Details
-
ButtonizeHelper
public ButtonizeHelper(boolean useButtons)Creates a new buttonize event helper with the default map implementation (LinkedHashMap).- Parameters:
useButtons- Whether to use interaction buttons or legacy reaction-based buttons.
-
ButtonizeHelper
public ButtonizeHelper(Map<net.dv8tion.jda.api.entities.emoji.Emoji,ThrowingConsumer<ButtonWrapper>> buttons, boolean useButtons)Creates a new buttonize event helper with the supplied map.- Parameters:
buttons- A map containing the initial buttons.useButtons- Whether to use interaction buttons or legacy reaction-based buttons.
-
-
Method Details
-
addAction
public ButtonizeHelper addAction(net.dv8tion.jda.api.entities.emoji.Emoji emoji, ThrowingConsumer<ButtonWrapper> action)Adds a new button to the map.- Parameters:
emoji- The emoji representing this button.action- The action to be performed on click.- Returns:
- The
ButtonizeHelperinstance for chaining convenience.
-
getOnFinalization
Retrieves theConsumerthat'll be executed when the event ends.- Returns:
- The action to be performed during finalization.
-
setOnFinalization
public ButtonizeHelper setOnFinalization(Consumer<net.dv8tion.jda.api.entities.Message> onFinalization)Defines an action to be executed when the event finishes, either by user action or timed finalization.- Parameters:
onFinalization- The action to be performed.- Returns:
- The
ButtonizeHelperinstance for chaining convenience.
-
getComponents
public <Out extends net.dv8tion.jda.api.utils.messages.MessageRequest<Out>> List<net.dv8tion.jda.api.interactions.components.LayoutComponent> getComponents(Out action)Description copied from class:BaseHelperRetrieves theListofComponents generated by this helper.- Specified by:
getComponentsin classBaseHelper<ButtonizeHelper,Map<net.dv8tion.jda.api.entities.emoji.Emoji,ThrowingConsumer<ButtonWrapper>>>- Type Parameters:
Out- Generic for aMessageRequest- Parameters:
action- A message event (either create or edit).- Returns:
- The list of components.
-
shouldUpdate
public boolean shouldUpdate(net.dv8tion.jda.api.entities.Message msg)Calculates whether theMessageneeds to have buttons applied onto or not.- Specified by:
shouldUpdatein classBaseHelper<ButtonizeHelper,Map<net.dv8tion.jda.api.entities.emoji.Emoji,ThrowingConsumer<ButtonWrapper>>>- Parameters:
msg- TheMessageto be checked.- Returns:
- Whether it needs to be updated or not.
-