Skip to content

Commit

Permalink
feat(PaginatedMessage): add method to update pages after response (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
killbasa committed May 2, 2023
1 parent 115eac5 commit db13068
Showing 1 changed file with 25 additions and 0 deletions.
Expand Up @@ -483,6 +483,31 @@ export class PaginatedMessage {
return this;
}

/**
* Update the current page.
* @param page The content to update the page with.
*/
public async updateCurrentPage(page: PaginatedMessagePage): Promise<this> {
if (this.response === null) {
throw new Error('You cannot update a page before responding to the interaction.');
}

const currentIndex = this.index;

this.pages[currentIndex] = page;
const messagePage = await this.handlePageLoad(page, currentIndex);
this.messages[currentIndex] = messagePage;

await safelyReplyToInteraction({
messageOrInteraction: this.response,
interactionEditReplyContent: messagePage,
interactionReplyContent: { ...this.#thisMazeWasNotMeantForYouContent, ephemeral: true },
componentUpdateContent: messagePage
});

return this;
}

/**
* Adds a page to the existing ones using a {@link MessageBuilder}. This will be added as the last page.
* @param builder Either a callback whose first parameter is `new MessageBuilder()`, or an already constructed {@link MessageBuilder}
Expand Down

0 comments on commit db13068

Please sign in to comment.