diff --git a/menu/src/main/java/com/jagrosh/jdautilities/menu/ButtonEmbedPaginator.java b/menu/src/main/java/com/jagrosh/jdautilities/menu/ButtonEmbedPaginator.java index 39835bac..51b82c19 100644 --- a/menu/src/main/java/com/jagrosh/jdautilities/menu/ButtonEmbedPaginator.java +++ b/menu/src/main/java/com/jagrosh/jdautilities/menu/ButtonEmbedPaginator.java @@ -24,6 +24,7 @@ import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; +import net.dv8tion.jda.api.interactions.InteractionHook; import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; import net.dv8tion.jda.api.requests.RestAction; @@ -101,6 +102,19 @@ public void display(Message message) { paginate(message, 1); } + /** + * Begins pagination on page 1 displaying this by editing the provided {@link InteractionHook} + * + *
Starting on another page is available via
+ * {@link Paginator#paginate(InteractionHook, int) Paginator#paginate(InteractionHook, int)}
+ *
+ * @param hook
+ * The InteractionHook to display the Menu in
+ */
+ public void display(InteractionHook hook) {
+ paginate(hook, 1);
+ }
+
/**
* Begins pagination as a new {@link Message} in the provided {@link MessageChannel}, starting on whatever
* page number is provided.
@@ -133,6 +147,24 @@ else if (pageNum > embeds.size())
initialize(message.editMessage(msg), pageNum);
}
+ /**
+ * Begins pagination displaying this by editing the provided
+ * {@link InteractionHook}, starting on whatever page number is provided.
+ *
+ * @param hook
+ * The InteractionHook to edit
+ * @param pageNum
+ * The page number to begin on
+ */
+ public void paginate(InteractionHook hook, int pageNum) {
+ if(pageNum<1)
+ pageNum = 1;
+ else if (pageNum > embeds.size())
+ pageNum = embeds.size();
+ MessageEditData msg = renderPage(pageNum);
+ initialize(hook.editOriginal(msg), pageNum);
+ }
+
private void initialize(RestAction Starting on another page is available via
+ * {@link Paginator#paginate(InteractionHook, int) Paginator#paginate(InteractionHook, int)}
+ *
+ * @param hook
+ * The InteractionHook to display the Menu in
+ */
+ public void display(InteractionHook hook) {
+ paginate(hook, 1);
+ }
+
/**
* Begins pagination as a new {@link net.dv8tion.jda.api.entities.Message Message}
* in the provided {@link MessageChannel}, starting
@@ -146,6 +160,24 @@ else if(pageNum > embeds.size())
initialize(message.editMessage(msg), pageNum);
}
+ /**
+ * Begins pagination by editing the provided
+ * {@link InteractionHook}, starting on whatever page number is provided.
+ *
+ * @param hook
+ * The InteractionHook to edit
+ * @param pageNum
+ * The page number to begin on
+ */
+ public void paginate(InteractionHook hook, int pageNum) {
+ if(pageNum < 1)
+ pageNum = 1;
+ else if (pageNum > embeds.size())
+ pageNum = embeds.size();
+ MessageEditData msg = renderPage(pageNum);
+ initialize(hook.editOriginal(msg), pageNum);
+ }
+
private void initialize(RestAction Starting on another page is available via
+ * {@link Paginator#paginate(InteractionHook, int) Paginator#paginate(InteractionHook, int)}
+ *
+ * @param hook
+ * The InteractionHook to display the Menu in
+ */
+ public void display(InteractionHook hook) {
+ paginate(hook, 1);
+ }
+
/**
* Begins pagination as a new {@link net.dv8tion.jda.api.entities.Message Message}
* in the provided {@link MessageChannel}, starting
@@ -180,6 +194,24 @@ else if (pageNum>pages)
initialize(message.editMessage(msg), pageNum);
}
+ /**
+ * Begins pagination displaying this Pagination by editing the provided
+ * {@link InteractionHook}, starting on whatever page number is provided.
+ *
+ * @param hook
+ * The InteractionHook to edit
+ * @param pageNum
+ * The page number to begin on
+ */
+ public void paginate(InteractionHook hook, int pageNum) {
+ if(pageNum<1)
+ pageNum = 1;
+ else if (pageNum>pages)
+ pageNum = pages;
+ MessageEditData msg = renderPage(pageNum);
+ initialize(hook.editOriginal(msg), pageNum);
+ }
+
private void initialize(RestAction