const pagination = new Pagination(interaction, {
firstEmoji: "⏮",
prevEmoji: "◀️",
nextEmoji: "▶️",
lastEmoji: "⏭",
limit: 5,
idle: 5 * 60 * 1000,
ephemeral: false,
prevDescription: "",
postDescription: "",
attachments: [],
buttonStyle: "SECONDARY",
loop: false,
});
The message or interaction to reply with the pagination message
The pagination options
The action rows of the final message.
The attachments to show with the paginated messages.
[]
All the authorized users who can use the pagination buttons
Readonly
buttonPagination button infos.
defaultOptions.buttonInfo
The pagination buttons.
Optional
collectorThe collector of the pagination.
The current page number.
Readonly
dataThe API data associated with this embed.
The descriptions to paginate through.
The embeds if paginating through embeds.
[]
Whether the reply should be ephemeral or not.
false
Whether if paginating through embed's fields.
false
The idle time before closing.
5 * 60 * 1_000
The images to paginate through.
Readonly
interactionThe interaction that the paginator is for.
The limit of entries per page.
5
Whether to loop through the pages or not.
false
The description to show after the paginated descriptions.
""
The description to show before the paginated descriptions.
""
The total number of entries.
The total number of pages.
Adds a custom action row below or above the pagination button action row.
const pagination = new Pagination(interaction)
.addActionRows([new ActionRowBuilder()], ExtraRowPosition.Below);
The action rows to add
The position where the action rows to be added
Adds an attachment to the existing attachments.
const pagination = new Pagination(interaction)
.setAttachments([new AttachmentBuilder()])
.addAttachment(new AttachmentBuilder());
The attachment to add
Adds multiple attachments to the existing attachments.
const pagination = new Pagination(interaction)
.setAttachments([new AttachmentBuilder()])
.addAttachments([new AttachmentBuilder(), new AttachmentBuilder()]);
The attachments to add
Adds a authorized user who can use these pagination buttons.
const pagination = new Pagination(interaction)
.addAuthorizedUser(userId1);
The user to add
Adds multiple authorized users who can use these pagination buttons.
const pagination = new Pagination(interaction)
.addAuthorizedUsers([userId1, userId2, userId3]);
The users to add
Adds multiple pagination descriptions.
const pagination = new Pagination(interaction)
.setDescriptions(["1st description", "2nd description", "3rd description"])
.addDescriptions(["4st description", "5nd description", "6rd description"]);
Rest
...descriptions: RestOrArray<string>The descriptions to set
Adds multiple pagination embeds.
const pagination = new Pagination(interaction)
.setEmbeds([new EmbedBuilder(), new EmbedBuilder(), new EmbedBuilder()])
.addEmbeds([new EmbedBuilder(), new EmbedBuilder(), new EmbedBuilder()]);
An array of EmbedBuilder or APIEmbed
Optional
template: ((embed) => JSONEncodable<APIEmbed>)A template function that will be called for each embed.
Appends fields to the embed
This method accepts either an array of fields or a variable number of field parameters. The maximum amount of fields that can be added is 25.
Using an array
const fields: APIEmbedField[] = ...;
const pagination = new Pagination(interaction)
.addFields(fields);
Using rest parameters (variadic)
const pagination = new Pagination(interaction)
.addFields(
{ name: 'Field 1', value: 'Value 1' },
{ name: 'Field 2', value: 'Value 2' },
);
Rest
...fields: RestOrArray<APIEmbedField>The fields to add
Adds multiple pagination images.
const pagination = new Pagination(interaction)
.setImages(["1st image", "2nd image", "3rd image"])
.addImages(["4st image", "5nd image", "6rd image"]);
Rest
...images: RestOrArray<string>The images to set
Protected
goProtected
goProtected
goProtected
goTriggers the pagination to go to a specific page.
const pagination = new Pagination(interaction)
.setLimit(1)
.setDescriptions(["1st page", "2nd page", "3rd page", "4th page", "5th page"]);
...
pagination.goToPage(2);
The page number to jump to
Makes the pagination interactive.
const pagination = new Pagination(interaction);
...
pagination.paginate(message);
The message to listen for interactions
Paginates through fields. It will be ignored if you are not paginating through fields.
const pagination = new Pagination(interaction)
.setFields([{
name: "Field 1",
value: "Field 1 value",
},
{
name: "Field 2",
value: "Field 2 value",
}])
.paginateFields();
Whether to paginate fields
Sends the final message.
By default, it will send as a reply to the message
but if the interaction is already replied or deferred then it will editReply
.
If you want to send follow-up or update the interaction, then use followUp or update instead.
const pagination = new Pagination(interaction);
...
pagination.render();
Sends an attachment along with the embed.
const pagination = new Pagination(interaction)
.setAttachments([new AttachmentBuilder()]);
The attachments to set
Sets the author of this embed.
The options to use
Sets authorized users who can use these pagination buttons. Leave it a empty array to allow everyone to use the pagination.
const pagination = new Pagination(interaction)
.setAuthorizedUsers([userId1, userId2, userId3]);
The users to set
Customizes the styles of each button.
const pagination = new Pagination(interaction)
.setButtonAppearance({
first: {
label: "First",
emoji: ":first_emoji:",
style: ButtonStyle.Secondary
}
});
The styles of the buttons
Set pagination buttons
Optional
buttons: Record<string, ButtonBuilder>The buttons to set
Sends contents along with the embed.
const pagination = new Pagination(interaction)
.setContents(["this is the first page", "this is the second page"]);
The contents to send.
Sets the description of this embed.
The description to use
Sets the pagination descriptions.
const pagination = new Pagination(interaction)
.setDescriptions(["1st description", "2nd description", "3rd description"]);
Rest
...descriptions: RestOrArray<string>The descriptions to set
Sets the pagination embeds. Note: if you set this then all other pagination methods and embed methods will be ignored i.e., descriptions, images, fields, also the embed properties like title, footer and all
const pagination = new Pagination(interaction)
.setEmbeds([new EmbedBuilder(), new EmbedBuilder(), new EmbedBuilder()]);
The embeds to set
Optional
template: ((embed, i, array) => JSONEncodable<APIEmbed>)A template function that will be called for each embed.
Sets the emojis for the buttons.
const pagination = new Pagination(interaction)
.setEmojis({
firstEmoji: ":first_emoji:",
prevEmoji: ":prev_emoji:",
nextEmoji: ":next_emoji:",
lastEmoji: ":last_emoji:"
});
The emoji options to set
Set whether the pagination reply should be ephemeral or not.
const pagination = new Pagination(interaction)
.setEphemeral(true);
Whether the reply should be ephemeral
Sets the embed's fields
This method is an alias for spliceFields. More specifically, it splices the entire array of fields, replacing them with the provided fields.
You can set a maximum of 25 fields.
Rest
...fields: RestOrArray<APIEmbedField>The fields to set
Sets the footer of this embed.
The footer to use
Sets the idle time before closing for the pagination.
const pagination = new Pagination(interaction)
.setIdle(5 * 60 * 1000);
The idle time
Sets the image of this embed.
The image URL to use
Sets the pagination images.
const pagination = new Pagination(interaction)
.setImages(["1st image", "2nd image", "3rd image"]);
Rest
...images: RestOrArray<string>The images to set
Sets the labels for the buttons.
const pagination = new Pagination(interaction)
.setLabels({
firstLabel: "first",
prevLabel: "prev",
nextLabel: "next",
lastLabel: "last"
});
The label options to set
Sets the limit of entries per page for pagination.
const pagination = new Pagination(interaction)
.setLimit(5);
Limit of entries per page
Sets the pagination options.
const pagination = new Pagination(interaction)
.setOptions({
firstEmoji: "⏮",
prevEmoji: "◀️",
nextEmoji: "▶️",
lastEmoji: "⏭",
limit: 5,
idle: 5 * 60 * 1000,
ephemeral: false,
prevDescription: "",
postDescription: "",
attachments: [],
buttonStyle: ButtonStyle.Secondary,
loop: false,
});
The pagination options
Sets a fixed post description which will be shown in all pages after the paginated descriptions. It will be ignored if you are not paginating through descriptions.
const pagination = new Pagination(interaction)
.setPostDescription("role id: 123456789");
The post description to set
Sets a fixed prev description which will be shown in all pages before the paginated descriptions. It will be ignored if you are not paginating through descriptions.
const pagination = new Pagination(interaction)
.setPrevDescription("role info");
The prev description to set
Sets the buttons' style.
const pagination = new Pagination(interaction)
.setStyle(ButtonStyle.Secondary);
The style of the buttons
Sets the thumbnail of this embed.
The thumbnail URL to use
Sets the timestamp of this embed.
Optional
timestamp: null | number | DateThe timestamp or date to use
Sets the title for this embed.
The title to use
Sets the URL of this embed.
The URL to use
Removes, replaces, or inserts fields in the embed.
This method behaves similarly to Array.prototype.splice. The maximum amount of fields that can be added is 25.
It's useful for modifying and adjusting order of the already-existing fields of an embed.
Remove the first field
pagination.spliceFields(0, 1);
Remove the first n fields
const n = 4
pagination.spliceFields(0, n);
Remove the last field
pagination.spliceFields(-1, 1);
The index to start at
The number of fields to remove
Rest
...fields: APIEmbedField[]The replacing field objects
Static
fromGenerated using TypeDoc
The pagination class.