Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PaginationEmbed<Element>

The base class for Pagination Modes. Do not invoke.

extends

EventEmitter

Type parameters

  • Element

Hierarchy

Index

Constructors

constructor

Events

on

  • on(event: "start", listener: function): this
  • on(event: "finish", listener: ListenerUser): this
  • on(event: "pageUpdate", listener: function): this
  • on(event: "react", listener: ListenerReact): this
  • on(event: "expire", listener: function): this
  • on(event: "error", listener: ListenerError): this
  • 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 this

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

    Parameters

    Returns this

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

    Parameters

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

    Returns this

  • Emitted upon a user reacting on the instance.

    Parameters

    Returns this

  • Emitted when the awaiting timeout is reached.

    Parameters

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

    Returns this

  • Emitted upon an occurance of error.

    Parameters

    Returns this

once

  • once(event: "finish", listener: ListenerUser): this
  • once(event: "start" | "expire" | "pageUpdate", listener: function): this
  • once(event: "react", listener: ListenerReact): this
  • once(event: "error", listener: ListenerError): this

Properties

array

array: Element[]

An array of elements to paginate.

authorizedUsers

authorizedUsers: Snowflake[]

The authorized users to navigate the pages. Default: everyone

channel

channel: TextChannel | DMChannel

The channel where to send the embed.

clientAssets

clientAssets: ClientAssets

Settings for assets for the client.

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

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

Methods

addFunctionEmoji

  • addFunctionEmoji(emoji: string, callback: function): this
  • 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 this

build

  • build(): void

deleteFunctionEmoji

  • deleteFunctionEmoji(emoji: string): this
  • Deletes a function emoji.

    Parameters

    • emoji: string

      The emoji key to delete.

    Returns this

resetEmojis

  • resetEmojis(): this
  • Deletes all function emojis, and then re-enables all navigation emojis.

    Returns this

setArray

  • setArray(array: Element[]): this
  • 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 this

setAuthorizedUsers

  • setAuthorizedUsers(users: Snowflake | Snowflake[]): this
  • Set the authorized users to navigate the pages.

    Parameters

    • users: Snowflake | Snowflake[]

      A user ID or an array of user IDs.

    Returns this

setChannel

  • setChannel(channel: TextChannel | DMChannel): this
  • The channel where to send the embed.

    Parameters

    • channel: TextChannel | DMChannel

      The channel object.

    Returns this

setClientAssets

setDeleteOnTimeout

  • setDeleteOnTimeout(boolean: boolean): this
  • Sets whether the client's message will be deleted upon timeout.

    Parameters

    • boolean: boolean

    Returns this

setDisabledNavigationEmojis

  • Sets the disabled navigation emojis.

    Example

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

    Parameters

    Returns this

setEmojisFunctionAfterNavigation

  • setEmojisFunctionAfterNavigation(boolean: boolean): this
  • Sets whether to set function emojis after navigation emojis.

    Parameters

    • boolean: boolean

      Set function emojis after navigation emojis?

    Returns this

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 this

setNavigationEmojis

  • Sets the emojis used for navigation emojis.

    Parameters

    • emojis: NavigationEmojis

      An object containing customised emojis to use as navigation emojis.

    Returns this

setPage

  • setPage(page: number | "back" | "forward"): this
  • Sets to jump to a certain page upon calling PaginationEmbed.build().

    Parameters

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

      The page number to jump to.

    Returns this

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: PageIndicatorPreMadeTypes | PageIndicatorCaster

      Function for indicator formatting.

    Returns this

setTimeout

  • setTimeout(timeout: number): this
  • Sets the time for awaiting a user action before timeout in ms.

    Parameters

    • timeout: number

      Timeout value in ms.

    Returns this

Generated using TypeDoc