diff --git a/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts b/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts index e0b6679804..ad628159b0 100644 --- a/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts +++ b/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts @@ -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 { + 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}