Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FieldsEmbed<Element>

A pagination mode that uses a MessageEmbed with a field(s) containing the elements to paginate.

extends

PaginationEmbed

Type parameters

  • Element

Hierarchy

Index

Constructors

constructor

Properties

elementsPerPage

elementsPerPage: number

Maximum number of elements to be displayed per page.

embed

embed: MessageEmbed

The MessageEmbed being used for this mode.

Notice

To customise the MessageEmbed for this mode, please access this property. Example:

<FieldsEmbed>.embed.setColor('red')

Accessors

elementList

  • get elementList(): Element[]

Methods

build

  • build(): Promise<void>
  • Build the Pagination Fields Embed.

    Example

      const { FieldsEmbed } = require('discord-paginationembed');
    
      // Under message event.
      new FieldsEmbed()
       .setAuthorizedUsers([message.author.id])
       .setChannel(message.channel)
       .setClientAssets({ prompt: 'Yo {{user}} wat peige?!?!?' })
       .setArray([{ name: 'John Doe' }, { name: 'Jane Doe' }])
       .setElementsPerPage(1)
       .setPageIndicator(false)
       .formatField('Name', el => el.name)
       .setPage(1)
       .setTimeout(69000)
       .setNavigationEmojis({
         back: '◀',
         jump: '↗',
         forward: '▶',
         delete: '🗑'
       })
       .setFunctionEmojis({
         '🔄': (user, instance) => {
           const field = instance.embed.fields[0];
    
           if (field.name === 'Name')
             field.name = user.tag;
           else
             field.name = 'Name';
         }
       })
       .build();```

    Returns Promise<void>

formatField

  • formatField(name: string, value: function, inline?: boolean): this
  • Adds a field to the embed. Same as MessageEmbed.addField, but value takes a function instead.

    Parameters

    • name: string

      Name of the field.

    • value: function

      Value of the field. Function for Array.prototype.map().join('\n').

        • (element: Element): any
        • Parameters

          • element: Element

          Returns any

    • Default value inline: boolean = true

      Whether the field is inline with other field. Default: true

    Returns this

setElementsPerPage

  • setElementsPerPage(max: number): this
  • Sets the maximum number of elements to be displayed per page.

    Parameters

    • max: number

      Maximum number of elements to be displayed per page.

    Returns this

Generated using TypeDoc