Package com.jagrosh.jdautilities.menu
Class EmbedPaginator.Builder
java.lang.Object
com.jagrosh.jdautilities.menu.Menu.Builder<EmbedPaginator.Builder,EmbedPaginator>
com.jagrosh.jdautilities.menu.EmbedPaginator.Builder
- Enclosing class:
EmbedPaginator
public static class EmbedPaginator.Builder
extends Menu.Builder<EmbedPaginator.Builder,EmbedPaginator>
The
Menu.Builder for
a EmbedPaginator.- Author:
- Andre_601
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAddsMessageEmbedsto the list of items to paginate.addItems(Collection<net.dv8tion.jda.api.entities.MessageEmbed> embeds) Adds the collection of providedMessageEmbedsto the list of items to paginate.addItems(net.dv8tion.jda.api.entities.MessageEmbed... embeds) AddsMessageEmbedsto the list of items to paginate.allowTextInput(boolean allowTextInput) Sets theEmbedPaginatorto allow a page number to be specified by a user via text.build()Builds theEmbedPaginatorwith this Builder.Clears all previously set items.setBulkSkipNumber(int bulkSkipNumber) Sets theEmbedPaginator's bulk-skip function to skip multiple pages using alternate forward and backwards reactions.setFinalAction(Consumer<net.dv8tion.jda.api.entities.Message> finalAction) Sets theConsumerto perform if theEmbedPaginatortimes out.Sets theMessageEmbedsto paginate.setItems(Collection<net.dv8tion.jda.api.entities.MessageEmbed> embeds) Sets theMessageEmbedsto paginate.setItems(net.dv8tion.jda.api.entities.MessageEmbed... embeds) Sets theMessageEmbedsto paginate.setLeftRightText(String left, String right) Sets theEmbedPaginatorto traverse left or right when a provided text input is sent in the form of a Message to theGuildChannelthe menu is displayed in.Sets the text of theMessageto be displayed when theEmbedPaginatoris built.setText(BiFunction<Integer, Integer, String> textBiFunction) Sets the text of theMessageto be displayed relative to the total page number and the current page as determined by the providedBiFunction.waitOnSinglePage(boolean waitOnSinglePage) Sets whether theEmbedPaginatorwill instantly timeout, and possibly run a providedRunnable, if only a single slide is available to display.wrapPageEnds(boolean wrapPageEnds) Sets theEmbedPaginatorto wrap from the last page to the first when traversing right and vice versa from the left.Methods inherited from class com.jagrosh.jdautilities.menu.Menu.Builder
addRoles, addUsers, setEventWaiter, setRoles, setTimeout, setUsers
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds theEmbedPaginatorwith this Builder.- Specified by:
buildin classMenu.Builder<EmbedPaginator.Builder,EmbedPaginator> - Returns:
- The Paginator built from this Builder.
- Throws:
IllegalArgumentException- If one of the following is violated:- No
EventWaiterwas set. - No items were set to paginate.
- No
-
setText
Sets the text of theMessageto be displayed when theEmbedPaginatoris built.- Parameters:
text- The Message content to be displayed above the embed when the EmbedPaginator is built.- Returns:
- This builder
-
setText
Sets the text of theMessageto be displayed relative to the total page number and the current page as determined by the providedBiFunction.
As the page changes, the BiFunction will re-process the current page number and the total page number, allowing for the displayed text of the Message to change depending on the page number.- Parameters:
textBiFunction- The BiFunction that uses both current and total page numbers, to get text for the Message- Returns:
- This builder
-
setFinalAction
public EmbedPaginator.Builder setFinalAction(Consumer<net.dv8tion.jda.api.entities.Message> finalAction) Sets theConsumerto perform if theEmbedPaginatortimes out.- Parameters:
finalAction- The Consumer action to perform if the EmbedPaginator times out- Returns:
- This builder
-
waitOnSinglePage
Sets whether theEmbedPaginatorwill instantly timeout, and possibly run a providedRunnable, if only a single slide is available to display.- Parameters:
waitOnSinglePage-trueif the EmbedPaginator will still generate- Returns:
- This builder
-
clearItems
Clears all previously set items.- Returns:
- This builder
-
addItems
AddsMessageEmbedsto the list of items to paginate.- Parameters:
embeds- The list of MessageEmbeds to add- Returns:
- This builder
-
addItems
public EmbedPaginator.Builder addItems(Collection<net.dv8tion.jda.api.entities.MessageEmbed> embeds) Adds the collection of providedMessageEmbedsto the list of items to paginate.- Parameters:
embeds- The collection of MessageEmbeds to add- Returns:
- This builder
-
addItems
AddsMessageEmbedsto the list of items to paginate.
This method creates a new, basic MessageEmbed containing only the provided String as description.
Use thePaginatorfor more Embed customization, without providing your own MessageEmbed instances.- Parameters:
items- The String list of items to add as MessageEmbeds- Returns:
- This builder
- Throws:
IllegalArgumentException- When one of the provided Strings is longer than 2048 characters.
-
setItems
Sets theMessageEmbedsto paginate.
This method clears all previously set items before setting.- Parameters:
embeds- The MessageEmbed list of items to add- Returns:
- This builder
-
setItems
public EmbedPaginator.Builder setItems(Collection<net.dv8tion.jda.api.entities.MessageEmbed> embeds) Sets theMessageEmbedsto paginate.
This method clears all previously set items before adding the provided collection of MessageEmbeds.- Parameters:
embeds- The collection of MessageEmbeds to set.- Returns:
- This builder
-
setItems
Sets theMessageEmbedsto paginate.
This method clears all previously set items before setting each String as a new MessageEmbed.
Use thePaginatorfor more Embed customization, without providing your own MessageEmbed instances.- Parameters:
items- The String list of items to add- Returns:
- This builder
- Throws:
IllegalArgumentException- When one of the provided Strings is longer than 2048 characters.
-
setBulkSkipNumber
Sets theEmbedPaginator's bulk-skip function to skip multiple pages using alternate forward and backwards reactions.- Parameters:
bulkSkipNumber- The number of pages to skip when the bulk-skip reactions are used.- Returns:
- This builder
-
wrapPageEnds
Sets theEmbedPaginatorto wrap from the last page to the first when traversing right and vice versa from the left.- Parameters:
wrapPageEnds-trueto enable wrapping.- Returns:
- This builder
-
allowTextInput
Sets theEmbedPaginatorto allow a page number to be specified by a user via text.Note that setting this doesn't mean that left and right text inputs provided via
setLeftRightText(String, String)will be invalidated if they were set previously! To invalidate those, providenullfor one or both of the parameters of that method.- Parameters:
allowTextInput-trueif the EmbedPaginator will allow page-number text input.- Returns:
- This builder
-
setLeftRightText
Sets theEmbedPaginatorto traverse left or right when a provided text input is sent in the form of a Message to theGuildChannelthe menu is displayed in.If one or both these parameters are provided
nullthis resets both of them and they will no longer be available when the Paginator is built.- Parameters:
left- The left text input, causes the EmbedPaginator to traverse one page left.right- The right text input, causes the EmbedPaginator to traverse one page right.- Returns:
- This builder
-