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 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 ButtonizeHelper instance for chaining convenience.
    • getOnFinalization

      public Consumer<net.dv8tion.jda.api.entities.Message> getOnFinalization()
      Retrieves the Consumer that'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 ButtonizeHelper instance 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: BaseHelper
      Retrieves the List of Components generated by this helper.
      Specified by:
      getComponents in class BaseHelper<ButtonizeHelper,​Map<net.dv8tion.jda.api.entities.emoji.Emoji,​ThrowingConsumer<ButtonWrapper>>>
      Type Parameters:
      Out - Generic for a MessageRequest
      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 the Message needs to have buttons applied onto or not.
      Specified by:
      shouldUpdate in class BaseHelper<ButtonizeHelper,​Map<net.dv8tion.jda.api.entities.emoji.Emoji,​ThrowingConsumer<ButtonWrapper>>>
      Parameters:
      msg - The Message to be checked.
      Returns:
      Whether it needs to be updated or not.