Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PaginationEmbed<Element>

The base class for Pagination Modes. Do not invoke.

Type parameters

  • Element

Hierarchy

Constructors

constructor

  • Type parameters

    • Element

    Returns PaginationEmbed<Element>

Events

on

  • Emitted after the initial embed has been sent (technically, after the client finished reacting with enabled navigation and function emojis).

    Parameters

    • event: "start"
    • listener: function
        • (): void
        • Returns void

    Returns PaginationEmbed<Element>

  • Emitted when the instance is finished by a user reacting with delete navigation emoji or a function emoji that throws non-Error type.

    Parameters

    • event: "finish"
    • listener: ListenerUser

    Returns PaginationEmbed<Element>

  • Emitted after the page number is updated and before the client sends the embed.

    Parameters

    • event: "pageUpdate"
    • listener: function
        • (): void
        • Returns void

    Returns PaginationEmbed<Element>

  • Emitted upon a user reacting on the instance.

    Parameters

    • event: "react"
    • listener: ListenerReact

    Returns PaginationEmbed<Element>

  • Emitted when the awaiting timeout is reached.

    Parameters

    • event: "expire"
    • listener: function
        • (): void
        • Returns void

    Returns PaginationEmbed<Element>

  • Emitted upon an occurance of error.

    Parameters

    • event: "error"
    • listener: ListenerError

    Returns PaginationEmbed<Element>

Properties

array

array: Element[]

An array of elements to paginate.

authorizedUsers

authorizedUsers: string[]

The authorized users to navigate the pages. Default: everyone

channel

channel: TextChannel | DMChannel | NewsChannel

The channel where to send the embed.

clientAssets

clientAssets: ClientAssets

Settings for assets for the client.

content

The client's message content options.

deleteOnTimeout

deleteOnTimeout: boolean

Whether the client's message will be deleted upon timeout. Default: false

disabledNavigationEmojis

disabledNavigationEmojis: ("back" | "jump" | "forward" | "delete" | "all")[]

The disabled navigation emojis. Available navigation emojis to disable:

  • 'back'
  • 'jump'
  • 'forward'
  • 'delete'
  • 'all'

emojisFunctionAfterNavigation

emojisFunctionAfterNavigation: boolean

Whether to set function emojis after navigation emojis. Default: false

functionEmojis

functionEmojis: FunctionEmoji<Element>

The emojis used for function emojis. Function emojis are user-customised message reactions for modifying the current instance of the pagination such as modifying embed texts, stopping the pagination, etc.

navigationEmojis

navigationEmojis: NavigationEmojis

The emojis used for navigation emojis. Navigation emojis are the default message reactions for navigating through the pagination.

page

page: number

The current page. Default: 1

Abstract pages

pages: number

Number of pages for this instance.

timeout

timeout: number

The time for awaiting a user action before timeout in ms. Default: 30000

usePageIndicator

usePageIndicator: boolean | "footer"

Whether to show page indicator, or put it in embed's footer text (replaces the existing text) instead. Default: false

Accessors

pageIndicator

  • get pageIndicator(): string
  • The formatted page indicator. Default format: text

    Returns string

Methods

addFunctionEmoji

  • addFunctionEmoji(emoji: string, callback: function): PaginationEmbed<Element>
  • Adds a function emoji to the embed.

    Example

     <PaginationEmbed>.addFunctionEmoji('πŸ…±', (_, instance) => {
       const field = instance.embed.fields[0];
    
       if (field.name.includes('πŸ…±'))
         field.name = 'Name';
       else
         field.name = 'NaπŸ…±e';
     });
    

    Parameters

    • emoji: string

      The emoji to use as the function's emoji.

    • callback: function

      The function to call upon pressing the function emoji.

    Returns PaginationEmbed<Element>

deleteFunctionEmoji

  • Deletes a function emoji.

    Parameters

    • emoji: string

      The emoji key to delete.

    Returns PaginationEmbed<Element>

resetEmojis

  • Deletes all function emojis, and then re-enables all navigation emojis.

    Returns PaginationEmbed<Element>

setArray

  • Sets the array of elements to paginate. This must be called first before any other methods.

    Parameters

    • array: Element[]

      An array of elements to paginate.

    Returns PaginationEmbed<Element>

setAuthorizedUsers

  • Set the authorized users to navigate the pages.

    Parameters

    • users: string | string[]

      A user ID or an array of user IDs.

    Returns PaginationEmbed<Element>

setChannel

  • setChannel(channel: TextChannel | DMChannel | NewsChannel): PaginationEmbed<Element>
  • The channel where to send the embed.

    Parameters

    • channel: TextChannel | DMChannel | NewsChannel

      The channel object.

    Returns PaginationEmbed<Element>

setClientAssets

  • Sets the settings for assets for the client.

    Parameters

    Returns PaginationEmbed<Element>

setContent

  • Sets the client's message content.

    Parameters

    • text: any

      The message content.

    • separator: string = '\n'

      The string to separate the content from the page indicator.

    Returns PaginationEmbed<Element>

setDeleteOnTimeout

  • Sets whether the client's message will be deleted upon timeout.

    Parameters

    • boolean: boolean

    Returns PaginationEmbed<Element>

setDisabledNavigationEmojis

  • Sets the disabled navigation emojis.

    Example

     // Disable specific navigation emojis
     <PaginationEmbed>.setDisabledNavigationEmojis(['delete', 'jump']);
    
     // Disable all navigation emojis
     <PaginationEmbed>.setDisabledNavigationEmojis(['all']);
    

    Parameters

    Returns PaginationEmbed<Element>

setEmojisFunctionAfterNavigation

  • setEmojisFunctionAfterNavigation(boolean: boolean): PaginationEmbed<Element>
  • Sets whether to set function emojis after navigation emojis.

    Parameters

    • boolean: boolean

      Set function emojis after navigation emojis?

    Returns PaginationEmbed<Element>

setFunctionEmojis

  • Sets the emojis used for function emojis.

    Example

     <PaginationEmbed>.setFunctionEmojis({
       'πŸ”„': (user, instance) => {
         const field = instance.embed.fields[0];
    
         if (field.name === 'Name')
           field.name = user.tag;
         else
           field.name = 'Name';
       }
     });
    

    Parameters

    • emojis: FunctionEmoji<Element>

      An object containing customised emojis to use as function emojis.

    Returns PaginationEmbed<Element>

setNavigationEmojis

  • Sets the emojis used for navigation emojis.

    Parameters

    • emojis: NavigationEmojis

      An object containing customised emojis to use as navigation emojis.

    Returns PaginationEmbed<Element>

setPage

  • Sets to jump to a certain page upon calling PaginationEmbed.build().

    Parameters

    • page: number | "back" | "forward"

      The page number to jump to.

    Returns PaginationEmbed<Element>

setPageIndicator

  • Sets the page indicator formatting function and placement.

    Parameters

    • enabled: boolean | "footer"

      Whether to show page indicator. Pass footer to display the indicator in embed's footer text (replaces existing text) instead.

    • Optional fn: PageIndicatorCaster | PageIndicatorPreMadeTypes

      Function for indicator formatting.

    Returns PaginationEmbed<Element>

setTimeout

  • Sets the time for awaiting a user action before timeout in ms.

    Parameters

    • timeout: number

      Timeout value in ms.

    Returns PaginationEmbed<Element>

Generated using TypeDoc