Package com.github.ygimenez.model
Class PaginatorBuilder
java.lang.Object
com.github.ygimenez.model.PaginatorBuilder
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 Summary
Modifier and TypeMethodDescriptionvoidactivate()Utility terminal operation that builds thePaginatorand activates it.build()Finishes building thePaginatorinstance, locking further modifications.static PaginatorBuilderCreates a newPaginatorBuilderinstance and begin customization, usebuild()to finish.static PaginatorBuildercreatePaginator(net.dv8tion.jda.api.JDA handler)Creates a newPaginatorBuilderinstance and begin customization, usebuild()to finish.static PaginatorBuildercreatePaginator(net.dv8tion.jda.api.sharding.ShardManager handler)Creates a newPaginatorBuilderinstance and begin customization, usebuild()to finish.static PaginatorcreateSimplePaginator(net.dv8tion.jda.api.JDA handler)Creates a newPaginatorinstance using default settings.static PaginatorcreateSimplePaginator(net.dv8tion.jda.api.sharding.ShardManager handler)Creates a newPaginatorinstance using default settings.net.dv8tion.jda.api.entities.emoji.EmojiRetrieve the configured handler for thisPaginatorBuilderinstance.booleanRetrieves whether events will be locked to prevent double-activation.setDeleteOnCancel(boolean deleteOnCancel)Set whetherMessageshould be deleted or not when the button handler is removed.setHandler(net.dv8tion.jda.api.JDA handler)Set the handler used for event processing.setHandler(net.dv8tion.jda.api.sharding.ShardManager handler)Set the handler used for event processing.booleanRetrieves whether theMessageshould be deleted or not when the button handler is removed.
If this is enabled, the bot will requirePermission.MESSAGE_MANAGEpermission for the deletion to work.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).shouldRemoveOnReact(boolean shouldRemove)Set whether user reactions will be removed after pressing the button or not.booleanRetrieves whether user reactions will be removed after pressing the button or not.
If this is enabled, the bot will requirePermission.MESSAGE_MANAGEpermission for the buttons to work.
-
Method Details
-
createPaginator
Creates a newPaginatorBuilderinstance and begin customization, usebuild()to finish.- Returns:
- The
PaginatorBuilderinstance for chaining convenience.
-
createPaginator
Creates a newPaginatorBuilderinstance and begin customization, usebuild()to finish.- Parameters:
handler- TheJDAinstance that'll be used for event processing.- Returns:
- The
PaginatorBuilderinstance for chaining convenience.
-
createPaginator
public static PaginatorBuilder createPaginator(@NotNull net.dv8tion.jda.api.sharding.ShardManager handler)Creates a newPaginatorBuilderinstance and begin customization, usebuild()to finish.- Parameters:
handler- TheShardManagerinstance that'll be used for event processing.- Returns:
- The
PaginatorBuilderinstance for chaining convenience.
-
createSimplePaginator
Creates a newPaginatorinstance using default settings.- Parameters:
handler- TheJDAinstance that'll be used for event processing.- Returns:
- The
PaginatorBuilderinstance for chaining convenience.
-
createSimplePaginator
public static Paginator createSimplePaginator(@NotNull net.dv8tion.jda.api.sharding.ShardManager handler)Creates a newPaginatorinstance using default settings.- Parameters:
handler- TheShardManagerinstance that'll be used for event processing.- Returns:
- The
PaginatorBuilderinstance for chaining convenience.
-
getHandler
Retrieve the configured handler for thisPaginatorBuilderinstance.- Returns:
- The handler object (will be either
JDAorShardManager).
-
setHandler
Set the handler used for event processing.- Parameters:
handler- TheJDAinstance that'll be used for event processing.- Returns:
- The
PaginatorBuilderinstance for chaining convenience.
-
setHandler
Set the handler used for event processing.- Parameters:
handler- TheShardManagerinstance that'll be used for event processing.- Returns:
- The
PaginatorBuilderinstance 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 requirePermission.MESSAGE_MANAGEpermission for the buttons to work.- Returns:
- Whether reactions will be removed on press or not.
-
shouldRemoveOnReact
Set whether user reactions will be removed after pressing the button or not. If this is enabled, the bot will requirePermission.MESSAGE_MANAGEpermission for the buttons to work.- Parameters:
shouldRemove- Whether reactions will be removed on press or not (default: false).- Returns:
- The
PaginatorBuilderinstance 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
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
PaginatorBuilderinstance for chaining convenience.
-
shouldDeleteOnCancel
public boolean shouldDeleteOnCancel()Retrieves whether theMessageshould be deleted or not when the button handler is removed.
If this is enabled, the bot will requirePermission.MESSAGE_MANAGEpermission for the deletion to work.- Returns:
- Whether the
Messagewill be deleted or not.
-
setDeleteOnCancel
Set whetherMessageshould be deleted or not when the button handler is removed. This must only be called byPaginatorBuilder.- Parameters:
deleteOnCancel- Whether theMessagewill be deleted or not (default: false).- Returns:
- The
PaginatorBuilderinstance for chaining convenience.
-
getEmote
-
setEmote
public PaginatorBuilder setEmote(@NotNull Emote emote, @NotNull String code) throws InvalidHandlerExceptionModify anEmote's code from theMap. Beware, the code must be either unicode orCustomEmoji's mention, else the buttons WILL NOT BE ADDED and will lead to errors.- Parameters:
emote- TheEmoteto be set.code- The newEmote's code.- Returns:
- The
PaginatorBuilderinstance for chaining convenience. - Throws:
InvalidHandlerException- If the configured handler is not aJDAorShardManagerobject.
-
setEmote
public PaginatorBuilder setEmote(@NotNull Emote emote, @NotNull net.dv8tion.jda.api.entities.emoji.Emoji emoji) throws InvalidHandlerException- Parameters:
emote- TheEmoteto be set.emoji- The newEmote'sEmoji.- Returns:
- The
PaginatorBuilderinstance for chaining convenience. - Throws:
InvalidHandlerException- If the configured handler is not aJDAorShardManagerobject.
-
build
Finishes building thePaginatorinstance, locking further modifications.- Returns:
- The
Paginatorinstance.
-
activate
Utility terminal operation that builds thePaginatorand activates it.- Throws:
AlreadyActivatedException- Thrown if there's a handler already set.InvalidHandlerException- Thrown if the handler isn't either aJDAorShardManagerobject.
-