Class PaginatorBuilder

java.lang.Object
com.github.ygimenez.model.PaginatorBuilder

public class PaginatorBuilder extends Object
Paginator's builder, this class allows you to customize Pagination-Utils' behavior as you like.
If you want a quick setup, use createSimplePaginator(JDA) or createSimplePaginator(ShardManager).
  • Method Details

    • createPaginator

      public static PaginatorBuilder createPaginator()
      Creates a new PaginatorBuilder instance and begin customization, use build() to finish.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • createPaginator

      public static PaginatorBuilder createPaginator(@NotNull net.dv8tion.jda.api.JDA handler)
      Creates a new PaginatorBuilder instance and begin customization, use build() to finish.
      Parameters:
      handler - The JDA instance that'll be used for event processing.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • createPaginator

      public static PaginatorBuilder createPaginator(@NotNull net.dv8tion.jda.api.sharding.ShardManager handler)
      Creates a new PaginatorBuilder instance and begin customization, use build() to finish.
      Parameters:
      handler - The ShardManager instance that'll be used for event processing.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • createSimplePaginator

      public static Paginator createSimplePaginator(@NotNull net.dv8tion.jda.api.JDA handler)
      Creates a new Paginator instance using default settings.
      Parameters:
      handler - The JDA instance that'll be used for event processing.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • createSimplePaginator

      public static Paginator createSimplePaginator(@NotNull net.dv8tion.jda.api.sharding.ShardManager handler)
      Creates a new Paginator instance using default settings.
      Parameters:
      handler - The ShardManager instance that'll be used for event processing.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • getHandler

      public Object getHandler()
      Retrieve the configured handler for this PaginatorBuilder instance.
      Returns:
      The handler object (will be either JDA or ShardManager).
    • setHandler

      public PaginatorBuilder setHandler(@NotNull net.dv8tion.jda.api.JDA handler)
      Set the handler used for event processing.
      Parameters:
      handler - The JDA instance that'll be used for event processing.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • setHandler

      public PaginatorBuilder setHandler(@NotNull net.dv8tion.jda.api.sharding.ShardManager handler)
      Set the handler used for event processing.
      Parameters:
      handler - The ShardManager instance that'll be used for event processing.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • willRemoveOnReact

      public boolean willRemoveOnReact()
      Retrieves whether user reactions will be removed after pressing the button or not.
      If this is enabled, the bot will require Permission.MESSAGE_MANAGE permission for the buttons to work.
      Returns:
      Whether reactions will be removed on press or not.
    • shouldRemoveOnReact

      public PaginatorBuilder shouldRemoveOnReact(boolean shouldRemove)
      Set whether user reactions will be removed after pressing the button or not. If this is enabled, the bot will require Permission.MESSAGE_MANAGE permission for the buttons to work.
      Parameters:
      shouldRemove - Whether reactions will be removed on press or not (default: false).
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • isEventLocking

      public boolean isEventLocking()
      Retrieves whether events will be locked to prevent double-activation.
      Returns:
      Whether events will be hash-locked.
    • shouldEventLock

      public PaginatorBuilder shouldEventLock(boolean shouldLock)
      Set whether evens should be locked to prevent double-activation of buttons before it finished previous processing (can help if experiencing race condition).
      Parameters:
      shouldLock - Whether events should be locked (default: false).
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • shouldDeleteOnCancel

      public boolean shouldDeleteOnCancel()
      Retrieves whether the Message should be deleted or not when the button handler is removed.
      If this is enabled, the bot will require Permission.MESSAGE_MANAGE permission for the deletion to work.
      Returns:
      Whether the Message will be deleted or not.
    • setDeleteOnCancel

      public PaginatorBuilder setDeleteOnCancel(boolean deleteOnCancel)
      Set whether Message should be deleted or not when the button handler is removed. This must only be called by PaginatorBuilder.
      Parameters:
      deleteOnCancel - Whether the Message will be deleted or not (default: false).
      Returns:
      The PaginatorBuilder instance for chaining convenience.
    • getEmote

      public net.dv8tion.jda.api.entities.emoji.Emoji getEmote(@NotNull Emote emote)
      Retrieves an Emote's code from the current emote Map.
      Parameters:
      emote - The Emote to be retrieved.
      Returns:
      The Emote's code.
    • setEmote

      public PaginatorBuilder setEmote(@NotNull Emote emote, @NotNull String code) throws InvalidHandlerException
      Modify an Emote's code from the Map. Beware, the code must be either unicode or CustomEmoji's mention, else the buttons WILL NOT BE ADDED and will lead to errors.
      Parameters:
      emote - The Emote to be set.
      code - The new Emote's code.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
      Throws:
      InvalidHandlerException - If the configured handler is not a JDA or ShardManager object.
    • setEmote

      public PaginatorBuilder setEmote(@NotNull Emote emote, @NotNull net.dv8tion.jda.api.entities.emoji.Emoji emoji) throws InvalidHandlerException
      Modify an Emote from the Map.
      Parameters:
      emote - The Emote to be set.
      emoji - The new Emote's Emoji.
      Returns:
      The PaginatorBuilder instance for chaining convenience.
      Throws:
      InvalidHandlerException - If the configured handler is not a JDA or ShardManager object.
    • build

      public Paginator build()
      Finishes building the Paginator instance, locking further modifications.
      Returns:
      The Paginator instance.
    • activate

      public void activate() throws InvalidHandlerException
      Utility terminal operation that builds the Paginator and activates it.
      Throws:
      AlreadyActivatedException - Thrown if there's a handler already set.
      InvalidHandlerException - Thrown if the handler isn't either a JDA or ShardManager object.