Package com.github.ygimenez.model.helper
Class PaginateHelper
java.lang.Object
com.github.ygimenez.model.helper.BaseHelper<PaginateHelper,List<Page>>
com.github.ygimenez.model.helper.PaginateHelper
Helper class for building paginate events, safe for reuse.
-
Constructor Summary
ConstructorsConstructorDescriptionPaginateHelper(boolean useButtons)Creates a new paginate event helper with the default list implementation (ArrayList).PaginateHelper(List<Page> pages, boolean useButtons)Creates a new paginate event helper with the supplied list. -
Method Summary
Modifier and TypeMethodDescriptionAdds a new page to the list.<Out extends net.dv8tion.jda.api.utils.messages.MessageRequest<Out>>
List<net.dv8tion.jda.api.interactions.components.LayoutComponent>getComponents(Out action)Retrieves theListofComponents generated by this helper.intRetrieves the configured amount of pages to be skipped on pressingEmote.SKIP_BACKWARDorEmote.SKIP_FORWARD.booleanRetrives whether this helper is configured to includeEmote.GOTO_FIRSTandEmote.GOTO_LASTbuttons.setFastForward(boolean fastForward)Set whether to includeEmote.GOTO_FIRSTandEmote.GOTO_LASTbuttons for quick navigation through the pages.setSkipAmount(int skipAmount)Set the amount of pages to be skipped on pressingEmote.SKIP_BACKWARDorEmote.SKIP_FORWARD.booleanshouldUpdate(net.dv8tion.jda.api.entities.Message msg)Calculates whether theMessageneeds to have buttons applied onto or not.Methods inherited from class com.github.ygimenez.model.helper.BaseHelper
apply, canInteract, getContent, getTimeout, isCancellable, isUsingButtons, setCancellable, setCanInteract, setTimeout
-
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
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
Adds a new page to the list.- Parameters:
page- The page to be added.- Returns:
- The
ButtonizeHelperinstance for chaining convenience.
-
getSkipAmount
public int getSkipAmount()Retrieves the configured amount of pages to be skipped on pressingEmote.SKIP_BACKWARDorEmote.SKIP_FORWARD.- Returns:
- The configured amount of pages to skip.
-
setSkipAmount
Set the amount of pages to be skipped on pressingEmote.SKIP_BACKWARDorEmote.SKIP_FORWARD.- Parameters:
skipAmount- The amount of pages to skip (default: 0).- Returns:
- The
ButtonizeHelperinstance for chaining convenience.
-
isFastForward
public boolean isFastForward()Retrives whether this helper is configured to includeEmote.GOTO_FIRSTandEmote.GOTO_LASTbuttons.- Returns:
- Whether to include fast-forward buttons.
-
setFastForward
Set whether to includeEmote.GOTO_FIRSTandEmote.GOTO_LASTbuttons for quick navigation through the pages.- Parameters:
fastForward- Whether to include fast-forward buttons (default: false).- Returns:
- The
ButtonizeHelperinstance 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:BaseHelperRetrieves theListofComponents generated by this helper.- Specified by:
getComponentsin classBaseHelper<PaginateHelper,List<Page>>- Type Parameters:
Out- Generic for aMessageRequest- 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 theMessageneeds to have buttons applied onto or not.- Specified by:
shouldUpdatein classBaseHelper<PaginateHelper,List<Page>>- Parameters:
msg- TheMessageto be checked.- Returns:
- Whether it needs to be updated or not.
-