Class PaginateHelper

java.lang.Object
com.github.ygimenez.model.helper.BaseHelper<PaginateHelper,​List<Page>>
com.github.ygimenez.model.helper.PaginateHelper

public class PaginateHelper extends BaseHelper<PaginateHelper,​List<Page>>
Helper class for building paginate events, safe for reuse.
  • Constructor Details

    • PaginateHelper

      public PaginateHelper(boolean useButtons)
      Creates a new paginate event helper with the default list implementation (ArrayList).
      Parameters:
      useButtons - Whether to use interaction buttons or legacy reaction-based buttons.
    • PaginateHelper

      public PaginateHelper(List<Page> pages, boolean useButtons)
      Creates a new paginate event helper with the supplied list.
      Parameters:
      pages - A list containing the initial pages.
      useButtons - Whether to use interaction buttons or legacy reaction-based buttons.
  • Method Details

    • addPage

      public PaginateHelper addPage(Page page)
      Adds a new page to the list.
      Parameters:
      page - The page to be added.
      Returns:
      The ButtonizeHelper instance for chaining convenience.
    • getSkipAmount

      public int getSkipAmount()
      Retrieves the configured amount of pages to be skipped on pressing Emote.SKIP_BACKWARD or Emote.SKIP_FORWARD.
      Returns:
      The configured amount of pages to skip.
    • setSkipAmount

      public PaginateHelper setSkipAmount(int skipAmount)
      Set the amount of pages to be skipped on pressing Emote.SKIP_BACKWARD or Emote.SKIP_FORWARD.
      Parameters:
      skipAmount - The amount of pages to skip (default: 0).
      Returns:
      The ButtonizeHelper instance for chaining convenience.
    • isFastForward

      public boolean isFastForward()
      Retrives whether this helper is configured to include Emote.GOTO_FIRST and Emote.GOTO_LAST buttons.
      Returns:
      Whether to include fast-forward buttons.
    • setFastForward

      public PaginateHelper setFastForward(boolean fastForward)
      Set whether to include Emote.GOTO_FIRST and Emote.GOTO_LAST buttons for quick navigation through the pages.
      Parameters:
      fastForward - Whether to include fast-forward buttons (default: false).
      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<PaginateHelper,​List<Page>>
      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<PaginateHelper,​List<Page>>
      Parameters:
      msg - The Message to be checked.
      Returns:
      Whether it needs to be updated or not.