Class PaginationEmbedAbstract

The PaginationEmbed class.

Hierarchy

Constructors

  • Example

    const pagination = new PaginationEmbed({
    firstEmoji: "⏮",
    prevEmoji: "◀️",
    nextEmoji: "▶️",
    lastEmoji: "⏭",
    limit: 5,
    idle: 5 * 60 * 1000,
    ephemeral: false,
    prevDescription: "",
    postDescription: "",
    attachments: [],
    buttonStyle: ButtonStyle.Secondary,
    loop: false,
    });

    Parameters

    • options: Partial<Options> = {}

      The pagination options

    Returns PaginationEmbed

Properties

actionRows: ActionRowBuilder<MessageActionRowComponentBuilder>[]

The action rows of the final message.

attachments: (BufferResolvable | Stream | JSONEncodable<APIAttachment> | Attachment | AttachmentBuilder | AttachmentPayload)[]

The attachments to show with the paginated messages.

Default Value

[]

buttonInfo: ButtonsOptions

Pagination button infos.

Default Value

defaultOptions.buttonInfo

buttons: Record<string, PButtonBuilder>

The pagination buttons.

changedButtons?: boolean

Changed default buttons

contents: null | string | (null | string)[]

Contents if changing contents per page.

Default Value

[]

currentPage: number

The current page number.

customFooter: boolean

Whether the footer is a custom footer or not.

data: APIEmbed

The API data associated with this embed.

descriptions: string[]

The descriptions to paginate through.

embeds: (APIEmbed | JSONEncodable<APIEmbed>)[]

The embeds if paginating through embeds.

Default Value

[]

ephemeral: boolean

Whether the reply should be ephemeral or not.

Default Value

false

extraRows: {
    position: ExtraRowPosition;
    rows: ActionRowBuilder<MessageActionRowComponentBuilder>[];
}[]

The extra action rows to add, if any.

Default Value

[]

fieldPaginate: boolean

Whether if paginating through embed's fields.

Default Value

false

idle: number

The idle time before closing.

Default Value

5 * 60 * 1_000

images: string[]

The images to paginate through.

limit: number

The limit of entries per page.

Default Value

5

loop: boolean

Whether to loop through the pages or not.

Default Value

false

mainActionRow: ActionRowBuilder<MessageActionRowComponentBuilder>

The main action row.

payload: Payload

The payload of the final message.

postDescription: string

The description to show after the paginated descriptions.

Default Value

""

prevDescription: string

The description to show before the paginated descriptions.

Default Value

""

rawFields: APIEmbedField[]

All the fields if paginating through fields.

rawFooter: string

The raw footer text.

totalEntry: number

The total number of entries.

totalPages: number

The total number of pages.

Methods

  • Adds a custom action row below or above the pagination button action row.

    Example

    const pagination = new Pagination(interaction)
    .addActionRows([new ActionRowBuilder()], ExtraRowPosition.Below);

    Parameters

    • actionRows: ActionRowBuilder<MessageActionRowComponentBuilder>[]

      The action rows to add

    • position: ExtraRowPosition = ExtraRowPosition.Below

      The position where the action rows to be added

    Returns PaginationEmbed

  • Adds an attachment to the existing attachments.

    Example

    const pagination = new Pagination(interaction)
    .setAttachments([new AttachmentBuilder()])
    .addAttachment(new AttachmentBuilder());

    Parameters

    • attachment: BufferResolvable | Stream | JSONEncodable<APIAttachment> | Attachment | AttachmentBuilder | AttachmentPayload

      The attachment to add

    Returns PaginationEmbed

  • Adds multiple attachments to the existing attachments.

    Example

    const pagination = new Pagination(interaction)
    .setAttachments([new AttachmentBuilder()])
    .addAttachments([new AttachmentBuilder(), new AttachmentBuilder()]);

    Parameters

    • attachments: (BufferResolvable | Stream | JSONEncodable<APIAttachment> | Attachment | AttachmentBuilder | AttachmentPayload)[]

      The attachments to add

    Returns PaginationEmbed

  • Adds multiple pagination descriptions.

    Example

    const pagination = new Pagination(interaction)
    .setDescriptions(["1st description", "2nd description", "3rd description"])
    .addDescriptions(["4st description", "5nd description", "6rd description"]);

    Parameters

    • Rest ...descriptions: RestOrArray<string>

      The descriptions to set

    Returns PaginationEmbed

  • Adds multiple pagination embeds.

    Example

    const pagination = new Pagination(interaction)
    .setEmbeds([new EmbedBuilder(), new EmbedBuilder(), new EmbedBuilder()])
    .addEmbeds([new EmbedBuilder(), new EmbedBuilder(), new EmbedBuilder()]);

    Parameters

    • embeds: (APIEmbed | JSONEncodable<APIEmbed>)[]

      An array of EmbedBuilder or APIEmbed

    • Optional template: ((embed) => JSONEncodable<APIEmbed>)

      A template function that will be called for each embed.

        • (embed): JSONEncodable<APIEmbed>
        • Parameters

          • embed: EmbedBuilder

          Returns JSONEncodable<APIEmbed>

    Returns PaginationEmbed

  • Appends fields to the embed

    Remarks

    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.

    Example

    Using an array

    const fields: APIEmbedField[] = ...;
    const pagination = new Pagination(interaction)
    .addFields(fields);

    Example

    Using rest parameters (variadic)

    const pagination = new Pagination(interaction)
    .addFields(
    { name: 'Field 1', value: 'Value 1' },
    { name: 'Field 2', value: 'Value 2' },
    );

    Parameters

    • Rest ...fields: RestOrArray<APIEmbedField>

      The fields to add

    Returns PaginationEmbed

  • Adds multiple pagination images.

    Example

    const pagination = new Pagination(interaction)
    .setImages(["1st image", "2nd image", "3rd image"])
    .addImages(["4st image", "5nd image", "6rd image"]);

    Parameters

    • Rest ...images: RestOrArray<string>

      The images to set

    Returns PaginationEmbed

  • Goes to the first page.

    Example

    const pagination = new Pagination(interaction);
    ...
    pagination.goFirst(i);

    Parameters

    • interaction: ButtonInteraction<CacheType>

      The interaction to reply to

    Returns Promise<void>

  • Goes to the last page.

    Example

    const pagination = new Pagination(interaction);
    ...
    pagination.goLast(i);

    Parameters

    • interaction: ButtonInteraction<CacheType>

      The interaction to reply to

    Returns Promise<void>

  • Goes to the next page.

    Example

    const pagination = new Pagination(interaction);
    ...
    pagination.goNext(i);

    Parameters

    • interaction: ButtonInteraction<CacheType>

      The interaction to reply to

    Returns Promise<void>

  • Goes to the previous page.

    Example

    const pagination = new Pagination(interaction);
    ...
    pagination.goPrev(i);

    Parameters

    • interaction: ButtonInteraction<CacheType>

      The interaction to reply to

    Returns Promise<void>

  • Triggers the pagination to go to a specific page.

    Example

    const pagination = new Pagination(interaction)
    .setLimit(1)
    .setDescriptions(["1st page", "2nd page", "3rd page", "4th page", "5th page"]);
    ...
    pagination.goToPage(2);

    Parameters

    • pageNumber: number

      The page number to jump to

    Returns PaginationEmbed

  • Paginates through fields. It will be ignored if you are not paginating through fields.

    Example

    const pagination = new Pagination(interaction)
    .setFields([{
    name: "Field 1",
    value: "Field 1 value",
    },
    {
    name: "Field 2",
    value: "Field 2 value",
    }])
    .paginateFields();

    Parameters

    • paginate: boolean = true

      Whether to paginate fields

    Returns PaginationEmbed

  • Sends an attachment along with the embed.

    Example

    const pagination = new Pagination(interaction)
    .setAttachments([new AttachmentBuilder()]);

    Parameters

    • attachments: (BufferResolvable | Stream | JSONEncodable<APIAttachment> | Attachment | AttachmentBuilder | AttachmentPayload)[]

      The attachments to set

    Returns PaginationEmbed

  • Sets the author of this embed.

    Parameters

    • options: null | EmbedAuthorOptions

      The options to use

    Returns PaginationEmbed

  • Parameters

    • color: null | ColorResolvable

    Returns PaginationEmbed

  • Sends contents along with the embed.

    Example

    const pagination = new Pagination(interaction)
    .setContents(["this is the first page", "this is the second page"]);

    Parameters

    • contents: null | string | (null | string)[]

      The contents to send.

    Returns PaginationEmbed

  • Sets the description of this embed.

    Parameters

    • description: null | string

      The description to use

    Returns PaginationEmbed

  • Sets the pagination descriptions.

    Example

    const pagination = new Pagination(interaction)
    .setDescriptions(["1st description", "2nd description", "3rd description"]);

    Parameters

    • Rest ...descriptions: RestOrArray<string>

      The descriptions to set

    Returns PaginationEmbed

  • 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

    Example

    const pagination = new Pagination(interaction)
    .setEmbeds([new EmbedBuilder(), new EmbedBuilder(), new EmbedBuilder()]);

    Parameters

    • embeds: (APIEmbed | JSONEncodable<APIEmbed>)[]

      The embeds to set

    • Optional template: ((embed, i, array) => JSONEncodable<APIEmbed>)

      A template function that will be called for each embed.

        • (embed, i, array): JSONEncodable<APIEmbed>
        • Parameters

          • embed: EmbedBuilder
          • i: number
          • array: (APIEmbed | JSONEncodable<APIEmbed>)[]

          Returns JSONEncodable<APIEmbed>

    Returns PaginationEmbed

  • Sets the embed's fields

    Remarks

    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.

    Parameters

    • Rest ...fields: RestOrArray<APIEmbedField>

      The fields to set

    Returns PaginationEmbed

  • Sets the footer of this embed.

    Parameters

    • options: null | EmbedFooterOptions

      The footer to use

    Returns PaginationEmbed

  • Sets the image of this embed.

    Parameters

    • url: null | string

      The image URL to use

    Returns PaginationEmbed

  • Sets the pagination options.

    Example

    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,
    });

    Parameters

    • options: Partial<Options>

      The pagination options

    Returns PaginationEmbed

  • 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.

    Example

    const pagination = new Pagination(interaction)
    .setPostDescription("role id: 123456789");

    Parameters

    • postDescription: string

      The post description to set

    Returns PaginationEmbed

  • 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.

    Example

    const pagination = new Pagination(interaction)
    .setPrevDescription("role info");

    Parameters

    • prevDescription: string

      The prev description to set

    Returns PaginationEmbed

  • Sets the thumbnail of this embed.

    Parameters

    • url: null | string

      The thumbnail URL to use

    Returns PaginationEmbed

  • Sets the timestamp of this embed.

    Parameters

    • Optional timestamp: null | number | Date

      The timestamp or date to use

    Returns PaginationEmbed

  • Sets the title for this embed.

    Parameters

    • title: null | string

      The title to use

    Returns PaginationEmbed

  • Sets the URL of this embed.

    Parameters

    • url: null | string

      The URL to use

    Returns PaginationEmbed

  • Removes, replaces, or inserts fields in the embed.

    Remarks

    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.

    Example

    Remove the first field

    pagination.spliceFields(0, 1);
    

    Example

    Remove the first n fields

    const n = 4
    pagination.spliceFields(0, n);

    Example

    Remove the last field

    pagination.spliceFields(-1, 1);
    

    Parameters

    • index: number

      The index to start at

    • deleteCount: number

      The number of fields to remove

    • Rest ...fields: APIEmbedField[]

      The replacing field objects

    Returns PaginationEmbed

  • Serializes this builder to API-compatible JSON data.

    Remarks

    This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.

    Returns APIEmbed

  • Parameters

    • other: APIEmbed | JSONEncodable<APIEmbed>

    Returns EmbedBuilder

Generated using TypeDoc