Skip to main content

Class: PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:32

This is a utility of PaginatedMessage, except it exclusively adds pagination inside a field of an embed. You must either use this class directly or extend it.

It differs from PaginatedMessageEmbedFields as the items here are the shape you want, and are then concatenated in a single field with a given formatter function, whereas PaginatedMessageEmbedFields takes fields as the items and add them to the embed.

Example​

import { PaginatedFieldMessageEmbed } from '@sapphire/discord.js-utilities';

new PaginatedFieldMessageEmbed()
.setTitleField('Test pager field')
.setTemplate({ embed })
.setItems([
{ title: 'Sapphire Framework', value: 'discord.js Framework' },
{ title: 'Sapphire Framework 2', value: 'discord.js Framework 2' },
{ title: 'Sapphire Framework 3', value: 'discord.js Framework 3' }
])
.formatItems((item) => `${item.title}\n${item.value}`)
.setItemsPerPage(2)
.make()
.run(message);

Extends​

Type Parameters​

Type Parameter
T

Constructors​

Constructor​

new PaginatedFieldMessageEmbed<T>(__namedParameters: PaginatedMessageOptions): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:518

Constructor for the PaginatedMessage class

Parameters​

ParameterTypeDescription
__namedParametersPaginatedMessageOptionsThe PaginatedMessageOptions for this instance of the PaginatedMessage class

Returns​

PaginatedFieldMessageEmbed<T>

Inherited from​

PaginatedMessage.constructor

Properties​

#thisMazeWasNotMeantForYouContent​

private readonly #thisMazeWasNotMeantForYouContent: object

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:511

The response we send when someone gets into an invalid flow

content​

content: string = "This maze wasn't meant for you...what did you do."

Inherited from​

PaginatedMessage.#thisMazeWasNotMeantForYouContent


actions​

actions: Map<string, PaginatedMessageAction>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:403

The actions which are to be used.

Inherited from​

PaginatedMessage.actions


collector​

collector: null | InteractionCollector<PaginatedMessageInteractionUnion> = null

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:393

The collector used for handling component interactions.

Inherited from​

PaginatedMessage.collector


constructor​

constructor: typeof PaginatedMessage

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1845

The constructor field represents the constructor of the PaginatedMessage interface. It is of type typeof PaginatedMessage, which means it refers to the type of the PaginatedMessage interface itself.

Inherited from​

PaginatedMessage.constructor


embedFooterSeparator​

embedFooterSeparator: string = PaginatedMessage.embedFooterSeparator

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:440

Custom separator to show after the page index in the embed footer. PaginatedMessage will automatically add a space ( ) after the given text. You do not have to add it yourself.

Default​

PaginatedMessage.embedFooterSeparator (static property)

Inherited from​

PaginatedMessage.embedFooterSeparator


embedTemplate​

private embedTemplate: APIEmbed

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:37

The embedTemplate field represents the template for the embed message. It is of type APIEmbed. It is initialized with a new EmbedBuilder instance converted to JSON.


emitPartialDMChannelWarning​

emitPartialDMChannelWarning: boolean = PaginatedMessage.emitPartialDMChannelWarning

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:454

Whether to emit the warning about running a PaginatedMessage in a DM channel without the client having the 'CHANNEL' partial.

Remark​

When using message based commands (as opposed to Application Commands) then you will also need to specify the DIRECT_MESSAGE intent for PaginatedMessage to work.

Default​

PaginatedMessage.emitPartialDMChannelWarning (static property)

Inherited from​

PaginatedMessage.emitPartialDMChannelWarning


fieldTitle​

private fieldTitle: string = ''

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:61

The fieldTitle field represents the title of the field in the embed message. It is of type string. It is initialized to an empty string.


hasEmittedMaxPageWarning​

protected hasEmittedMaxPageWarning: boolean = false

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:474

Tracks whether a warning was already emitted for this PaginatedMessage concerning the maximum amount of pages in the SelectMenu.

Default​

false

Inherited from​

PaginatedMessage.hasEmittedMaxPageWarning


hasEmittedPartialDMChannelWarning​

protected hasEmittedPartialDMChannelWarning: boolean = false

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:484

Tracks whether a warning was already emitted for this PaginatedMessage concerning the PaginatedMessage being called in a DMChannel without the client having the 'Channel' partial.

Remark​

When using message based commands (as opposed to Application Commands) then you will also need to specify the DIRECT_MESSAGE intent for PaginatedMessage to work.

Default​

false

Inherited from​

PaginatedMessage.hasEmittedPartialDMChannelWarning


idle​

idle: number

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:420

The amount of milliseconds to idle before the paginator is closed.

Default​

14.5 minutes

Remark​

This is to ensure it is a bit before interactions expire.

Inherited from​

PaginatedMessage.idle


index​

index: number = 0

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:413

The handler's current page/message index.

Inherited from​

PaginatedMessage.index


items​

private items: T[] = []

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:49

The items field represents the items to be displayed in the paginated message. It is an array of type T. It is initialized to an empty array.


itemsPerPage​

private itemsPerPage: number = 10

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:55

The itemsPerPage field represents the number of items to be displayed per page. It is of type number. It is initialized to 10.


messages​

messages: (null | PaginatedMessageResolvedPage)[] = []

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:398

The pages which were converted from PaginatedMessage.pages

Inherited from​

PaginatedMessage.messages


pageActions​

pageActions: (null | Map<string, PaginatedMessageAction>)[] = []

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:408

The page-specific actions which are to be used.

Inherited from​

PaginatedMessage.pageActions


pageIndexPrefix​

pageIndexPrefix: string = PaginatedMessage.pageIndexPrefix

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:433

Custom text to show in front of the page index in the embed footer. PaginatedMessage will automatically add a space ( ) after the given text. You do not have to add it yourself.

Default​

PaginatedMessage.pageIndexPrefix (static property)

Inherited from​

PaginatedMessage.pageIndexPrefix


pages​

pages: PaginatedMessagePage[] = []

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:383

The pages to be converted to PaginatedMessage.messages

Inherited from​

PaginatedMessage.pages


paginatedMessageData​

protected paginatedMessageData: null | Omit<PaginatedMessageMessageOptionsUnion, "components"> = null

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:461

Data for the paginated message.

Inherited from​

PaginatedMessage.paginatedMessageData


response​

response: null | Message<boolean> | AnyInteractableInteraction = null

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:388

The response message used to edit on page changes.

Inherited from​

PaginatedMessage.response


selectMenuOptions​

protected selectMenuOptions: PaginatedMessageSelectMenuOptionsFunction = PaginatedMessage.selectMenuOptions

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:501

Function that returns the select menu options for the paginated message.

Param​

The paginated message.

Returns​

The select menu options.

Inherited from​

PaginatedMessage.selectMenuOptions


selectMenuPlaceholder​

protected selectMenuPlaceholder: undefined | string = undefined

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:466

The placeholder for the select menu.

Inherited from​

PaginatedMessage.selectMenuPlaceholder


shouldAddFooterToEmbeds​

protected shouldAddFooterToEmbeds: boolean = true

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:494

Determines whether the default footer that shows the current page number should be added to the embeds.

Note​

If this is set to false, i.e.e through setShouldAddFooterToEmbeds, then embedFooterSeparator is never applied.

Default​

true

Inherited from​

PaginatedMessage.shouldAddFooterToEmbeds


stopPaginatedMessageCustomIds​

stopPaginatedMessageCustomIds: string[] = PaginatedMessage.stopPaginatedMessageCustomIds

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:446

A list of customId that are bound to actions that will stop the PaginatedMessage

Default​

PaginatedMessage.stopPaginatedMessageCustomIds (static property)

Inherited from​

PaginatedMessage.stopPaginatedMessageCustomIds


template​

template: PaginatedMessageMessageOptionsUnion

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:426

The template for this PaginatedMessage. You can use templates to set defaults that will apply to each and every page in the PaginatedMessage

Inherited from​

PaginatedMessage.template


totalPages​

private totalPages: number = 0

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:43

The totalPages field represents the total number of pages in the paginated message. It is of type number. It is initialized to 0.


wrongUserInteractionReply​

protected wrongUserInteractionReply: PaginatedMessageWrongUserInteractionReplyFunction = PaginatedMessage.wrongUserInteractionReply

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:506

Function that handles the reply when a user interacts with the paginated message incorrectly.

Inherited from​

PaginatedMessage.wrongUserInteractionReply


defaultActions​

static defaultActions: PaginatedMessageAction[]

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:144

The default actions of this handler.

Inherited from​

PaginatedMessage.defaultActions


deletionStopReasons​

static deletionStopReasons: string[]

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:230

The reasons sent by InteractionCollector#end event when the message (or its owner) has been deleted.

Inherited from​

PaginatedMessage.deletionStopReasons


embedFooterSeparator​

static embedFooterSeparator: string = '•'

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:260

Custom separator for the page index in the embed footer.

Default​

"•"

Remark​

To overwrite this property change it somewhere in a "setup" file, i.e. where you also call client.login() for your client. Alternatively, you can also customize it on a per-PaginatedMessage basis by passing embedFooterSeparator in the options of the constructor.

Example​

import { PaginatedMessage } from '@sapphire/discord.js-utilities';

PaginatedMessage.embedFooterSeparator = '|';
// This will make the separator of the embed footer something like "Page 1/2 | Today at 4:20"

Inherited from​

PaginatedMessage.embedFooterSeparator


emitPartialDMChannelWarning​

static emitPartialDMChannelWarning: boolean = true

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:210

Whether to emit the warning about running a PaginatedMessage in a DM channel without the client the 'CHANNEL' partial.

Remark​

When using message based commands (as opposed to Application Commands) then you will also need to specify the DIRECT_MESSAGE intent for PaginatedMessage to work.

Remark​

To overwrite this property change it somewhere in a "setup" file, i.e. where you also call client.login() for your client. Alternatively, you can also customize it on a per-PaginatedMessage basis by using paginatedMessageInstance.setEmitPartialDMChannelWarning(newBoolean)

Default​

true

Inherited from​

PaginatedMessage.emitPartialDMChannelWarning


handlers​

readonly static handlers: Map<string, PaginatedMessage>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:278

The current InteractionCollector handlers that are active. The key is the ID of of the author who sent the message that triggered this PaginatedMessage

This is to ensure that any given author can only trigger 1 PaginatedMessage. This is important for performance reasons, and users should not have more than 1 PaginatedMessage open at once.

Inherited from​

PaginatedMessage.handlers


messages​

readonly static messages: Map<string, PaginatedMessage>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:269

The messages that are currently being handled by a PaginatedMessage The key is the ID of the message that triggered this PaginatedMessage

This is to ensure that only 1 PaginatedMessage can run on a specified message at once. This is important when having an editable commands solution.

Inherited from​

PaginatedMessage.messages


pageIndexPrefix​

static pageIndexPrefix: string = ''

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:245

Custom text to show in front of the page index in the embed footer. PaginatedMessage will automatically add a space ( ) after the given text. You do not have to add it yourself.

Default​

""

Remark​

To overwrite this property change it somewhere in a "setup" file, i.e. where you also call client.login() for your client.

Example​

import { PaginatedMessage } from '@sapphire/discord.js-utilities';

PaginatedMessage.pageIndexPrefix = 'Page';
// This will make the footer of the embed something like "Page 1/2"

Inherited from​

PaginatedMessage.pageIndexPrefix


selectMenuOptions​

static selectMenuOptions: PaginatedMessageSelectMenuOptionsFunction

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:305

A generator for MessageSelectOption that will be used to generate the options for the StringSelectMenuBuilder. We do not allow overwriting the MessageSelectOption#value property with this, as it is vital to how we handle select menu interactions.

Param​

The index of the page to add to the StringSelectMenuBuilder. We will add 1 to this number because our pages are 0 based, so this will represent the pages as seen by the user.

Default​

{
label: `Page ${pageIndex}`
}

Remark​

To overwrite this property change it in a "setup" file prior to calling client.login() for your client.

Example​

import { PaginatedMessage } from '@sapphire/discord.js-utilities';

PaginatedMessage.selectMenuOptions = (pageIndex) => ({
label: `Go to page: ${pageIndex}`,
description: 'This is a description'
});

Inherited from​

PaginatedMessage.selectMenuOptions


stopPaginatedMessageCustomIds​

static stopPaginatedMessageCustomIds: string[]

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:224

A list of customId that are bound to actions that will stop the PaginatedMessage

Default​

['@sapphire/paginated-messages.stop']

Remark​

To overwrite this property change it somewhere in a "setup" file, i.e. where you also call client.login() for your client. Alternatively, you can also customize it on a per-PaginatedMessage basis by using paginatedMessageInstance.setStopPaginatedMessageCustomIds(customIds)

Example​

import { PaginatedMessage } from '@sapphire/discord.js-utilities';

PaginatedMessage.stopPaginatedMessageCustomIds = ['my-custom-stop-custom-id'];

Inherited from​

PaginatedMessage.stopPaginatedMessageCustomIds


wrongUserInteractionReply​

static wrongUserInteractionReply: PaginatedMessageWrongUserInteractionReplyFunction

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:352

A generator for MessageComponentInteraction#reply that will be called and sent whenever an untargeted user interacts with one of the buttons. When modifying this it is recommended that the message is set to be ephemeral so only the user that is pressing the buttons can see them. Furthermore, we also recommend setting allowedMentions: { users: [], roles: [] }, so you don't have to worry about accidentally pinging anyone.

When setting just a string, we will add { flags: MessageFlags.Ephemeral, allowedMentions: { users: [], roles: [] } } for you.

Param​

The User this PaginatedMessage was intended for.

Param​

The User that actually clicked the button.

Default​

import { userMention } from 'discord.js';

{
content: `Please stop interacting with the components on this message. They are only for ${userMention(targetUser.id)}.`,
flags: MessageFlags.Ephemeral,
allowedMentions: { users: [], roles: [] }
}

Remark​

To overwrite this property change it in a "setup" file prior to calling client.login() for your client.

Examples​

import { PaginatedMessage } from '@sapphire/discord.js-utilities';
import { userMention } from 'discord.js';

// We will add ephemeral and no allowed mention for string only overwrites
PaginatedMessage.wrongUserInteractionReply = (targetUser) =>
`These buttons are only for ${userMention(targetUser.id)}. Press them as much as you want, but I won't do anything with your clicks.`;
import { PaginatedMessage } from '@sapphire/discord.js-utilities';
import { userMention } from 'discord.js';

PaginatedMessage.wrongUserInteractionReply = (targetUser) => ({
content: `These buttons are only for ${userMention(
targetUser.id
)}. Press them as much as you want, but I won't do anything with your clicks.`,
flags: MessageFlags.Ephemeral,
allowedMentions: { users: [], roles: [] }
});

Inherited from​

PaginatedMessage.wrongUserInteractionReply

Methods​

addAction()​

addAction(action: PaginatedMessageAction): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:709

Adds an action to the existing ones. This will be added as the last action.

Parameters​

ParameterTypeDescription
actionPaginatedMessageActionThe action to add.

Returns​

this

See​

PaginatedMessage.setActions for examples on how to structure the action.

Inherited from​

PaginatedMessage.addAction


addActions()​

addActions(actions: PaginatedMessageAction[]): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:699

Adds actions to the existing ones. The order given is the order they will be used.

Parameters​

ParameterTypeDescription
actionsPaginatedMessageAction[]The actions to add.

Returns​

this

See​

PaginatedMessage.setActions for examples on how to structure the actions.

Inherited from​

PaginatedMessage.addActions


addAsyncPageBuilder()​

addAsyncPageBuilder(builder: MessageBuilder | (builder: MessageBuilder) => Promise<MessageBuilder>): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:859

Adds a page to the existing ones asynchronously using a MessageBuilder. This wil be added as the last page.

Parameters​

ParameterTypeDescription
builderMessageBuilder | (builder: MessageBuilder) => Promise<MessageBuilder>Either a callback whose first parameter is new MessageBuilder(), or an already constructed MessageBuilder

Returns​

this

Example​

const { PaginatedMessage } = require('@sapphire/discord.js-utilities');
const { EmbedBuilder } = require('discord.js');

const paginatedMessage = new PaginatedMessage()
.addAsyncPageBuilder(async (builder) => {
const someRemoteData = await fetch('https://contoso.com/api/users');

const embed = new EmbedBuilder()
.setColor('#FF0000')
.setDescription(someRemoteData.data);

return builder
.setContent('example content')
.setEmbeds([embed]);
});

Inherited from​

PaginatedMessage.addAsyncPageBuilder


addAsyncPageEmbed()​

addAsyncPageEmbed(embed: EmbedResolvable | (builder: EmbedBuilder) => Awaitable<EmbedResolvable>): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:929

Adds a page to the existing ones asynchronously using a EmbedBuilder. This wil be added as the last page.

Parameters​

ParameterTypeDescription
embedEmbedResolvable | (builder: EmbedBuilder) => Awaitable<EmbedResolvable>Either a callback whose first parameter is new EmbedBuilder(), or an already constructed EmbedBuilder

Returns​

this

Example​

const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const paginatedMessage = new PaginatedMessage()
.addAsyncPageEmbed(async (embed) => {
const someRemoteData = await fetch('https://contoso.com/api/users');

embed
.setColor('#FF0000')
.setDescription(someRemoteData.data);

return embed;
});

Inherited from​

PaginatedMessage.addAsyncPageEmbed


addAsyncPageEmbeds()​

addAsyncPageEmbeds(embeds: EmbedResolvable[] | (embed1: EmbedBuilder, embed2: EmbedBuilder, embed3: EmbedBuilder, embed4: EmbedBuilder, embed5: EmbedBuilder, embed6: EmbedBuilder, embed7: EmbedBuilder, embed8: EmbedBuilder, embed9: EmbedBuilder, embed10: EmbedBuilder) => Awaitable<EmbedResolvable[]>): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1071

Adds a page to the existing ones using multiple EmbedBuilder's. This wil be added as the last page.

Parameters​

ParameterTypeDescription
embedsEmbedResolvable[] | (embed1: EmbedBuilder, embed2: EmbedBuilder, embed3: EmbedBuilder, embed4: EmbedBuilder, embed5: EmbedBuilder, embed6: EmbedBuilder, embed7: EmbedBuilder, embed8: EmbedBuilder, embed9: EmbedBuilder, embed10: EmbedBuilder) => Awaitable<EmbedResolvable[]>Either a callback which receives 10 parameters of new EmbedBuilder(), or an array of already constructed EmbedBuilder's

Returns​

this

Remark​

When using this with a callback this will construct 10 EmbedBuilder's in the callback parameters, regardless of how many are actually used. If this a performance impact you do not want to cope with then it is recommended to use PaginatedMessage.addPageBuilder instead, which will let you add as many embeds as you want, albeit manually

Examples​

const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const paginatedMessage = new PaginatedMessage().addAsyncPageEmbeds(async (embed0, embed1, embed2) => {
const someRemoteData = (await fetch('https://contoso.com/api/users')) as any;

for (const [index, user] of Object.entries(someRemoteData.users.slice(0, 10)) as [`${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}`, any][]) {
switch (index) {
case '0': {
embed0.setColor('#FF0000').setDescription('example description 1').setAuthor(user.name);
break;
}
case '1': {
embed1.setColor('#00FF00').setDescription('example description 2').setAuthor(user.name);
break;
}
case '2': {
embed2.setColor('#0000FF').setDescription('example description 3').setAuthor(user.name);
break;
}
}
}

return [embed0, embed1, embed2];
});
const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const embed1 = new EmbedBuilder()
.setColor('#FF0000')
.setDescription('example description 1');

const embed2 = new EmbedBuilder()
.setColor('#00FF00')
.setDescription('example description 2');

const embed3 = new EmbedBuilder()
.setColor('#0000FF')
.setDescription('example description 3');

const paginatedMessage = new PaginatedMessage()
.addAsyncPageEmbeds([embed1, embed2, embed3]); // You can add up to 10 embeds

Inherited from​

PaginatedMessage.addAsyncPageEmbeds


addPage()​

addPage(page: PaginatedMessagePage): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:750

Adds a page to the existing ones. This will be added as the last page.

Parameters​

ParameterTypeDescription
pagePaginatedMessagePageThe page to add.

Returns​

this

Remark​

While you can use this method you should first check out PaginatedMessage.addPageBuilder, PaginatedMessage.addPageContent and PaginatedMessage.addPageEmbed as these are easier functional methods of adding pages and will likely already suffice for your needs.

Inherited from​

PaginatedMessage.addPage


addPageAction()​

addPageAction(action: PaginatedMessageAction, index: number): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1203

Add the provided action to a page.

Parameters​

ParameterTypeDescription
actionPaginatedMessageActionThe action to add.
indexnumberThe index of the page to add the action to.

Returns​

this

See​

PaginatedMessage.setActions for examples on how to structure the action.

Remark​

Internally we check if the provided index exists. This means that calling this function before calling any of the methods below this will not work as the amount of pages will always be 0, thus the index will always be out of bounds. That said, make sure you first define your pages and then define your actions for those pages.

Inherited from​

PaginatedMessage.addPageAction


addPageActions()​

addPageActions(actions: PaginatedMessageAction[], index: number): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1176

Add the provided actions to a page.

Parameters​

ParameterTypeDescription
actionsPaginatedMessageAction[]The actions to add.
indexnumberThe index of the page to add the actions to.

Returns​

this

See​

PaginatedMessage.setActions for examples on how to structure the actions.

Remark​

Internally we check if the provided index exists. This means that calling this function before calling any of the methods below this will not work as the amount of pages will always be 0, thus the index will always be out of bounds. That said, make sure you first define your pages and then define your actions for those pages.

Inherited from​

PaginatedMessage.addPageActions


addPageBuilder()​

addPageBuilder(builder: MessageBuilder | (builder: MessageBuilder) => MessageBuilder): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:833

Adds a page to the existing ones using a MessageBuilder. This will be added as the last page.

Parameters​

ParameterTypeDescription
builderMessageBuilder | (builder: MessageBuilder) => MessageBuilderEither a callback whose first parameter is new MessageBuilder(), or an already constructed MessageBuilder

Returns​

this

Examples​

const { PaginatedMessage } = require('@sapphire/discord.js-utilities');
const { EmbedBuilder } = require('discord.js');

const paginatedMessage = new PaginatedMessage()
.addPageBuilder((builder) => {
const embed = new EmbedBuilder()
.setColor('#FF0000')
.setDescription('example description');

return builder
.setContent('example content')
.setEmbeds([embed]);
});
const { EmbedBuilder } = require('discord.js');
const { MessageBuilder, PaginatedMessage } = require('@sapphire/discord.js-utilities');

const embed = new EmbedBuilder()
.setColor('#FF0000')
.setDescription('example description');

const builder = new MessageBuilder()
.setContent('example content')
.setEmbeds([embed]);

const paginatedMessage = new PaginatedMessage()
.addPageBuilder(builder);

Inherited from​

PaginatedMessage.addPageBuilder


addPageContent()​

addPageContent(content: string): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:874

Adds a page to the existing ones using simple message content. This will be added as the last page.

Parameters​

ParameterTypeDescription
contentstringThe content to set.

Returns​

this

Example​

const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const paginatedMessage = new PaginatedMessage()
.addPageContent('example content');

Inherited from​

PaginatedMessage.addPageContent


addPageEmbed()​

addPageEmbed(embed: EmbedResolvable | (embed: EmbedBuilder) => EmbedResolvable): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:906

Adds a page to the existing ones using a EmbedBuilder. This wil be added as the last page.

Parameters​

ParameterTypeDescription
embedEmbedResolvable | (embed: EmbedBuilder) => EmbedResolvableEither a callback whose first parameter is new EmbedBuilder(), or an already constructed EmbedBuilder

Returns​

this

Examples​

const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const paginatedMessage = new PaginatedMessage()
.addPageEmbed((embed) => {
embed
.setColor('#FF0000')
.setDescription('example description');

return embed;
});
const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const embed = new EmbedBuilder()
.setColor('#FF0000')
.setDescription('example description');

const paginatedMessage = new PaginatedMessage()
.addPageEmbed(embed);

Inherited from​

PaginatedMessage.addPageEmbed


addPageEmbeds()​

addPageEmbeds(embeds: EmbedResolvable[] | (embed1: EmbedBuilder, embed2: EmbedBuilder, embed3: EmbedBuilder, embed4: EmbedBuilder, embed5: EmbedBuilder, embed6: EmbedBuilder, embed7: EmbedBuilder, embed8: EmbedBuilder, embed9: EmbedBuilder, embed10: EmbedBuilder) => EmbedResolvable[]): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:980

Adds a page to the existing ones asynchronously using multiple EmbedBuilder's. This wil be added as the last page.

Parameters​

ParameterTypeDescription
embedsEmbedResolvable[] | (embed1: EmbedBuilder, embed2: EmbedBuilder, embed3: EmbedBuilder, embed4: EmbedBuilder, embed5: EmbedBuilder, embed6: EmbedBuilder, embed7: EmbedBuilder, embed8: EmbedBuilder, embed9: EmbedBuilder, embed10: EmbedBuilder) => EmbedResolvable[]Either a callback which receives 10 parameters of new EmbedBuilder(), or an array of already constructed EmbedBuilder's

Returns​

this

Remark​

When using this with a callback this will construct 10 EmbedBuilder's in the callback parameters, regardless of how many are actually used. If this a performance impact you do not want to cope with then it is recommended to use PaginatedMessage.addPageBuilder instead, which will let you add as many embeds as you want, albeit manually

Examples​

const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const paginatedMessage = new PaginatedMessage()
.addPageEmbeds((embed1, embed2, embed3) => { // You can add up to 10 embeds
embed1
.setColor('#FF0000')
.setDescription('example description 1');

embed2
.setColor('#00FF00')
.setDescription('example description 2');

embed3
.setColor('#0000FF')
.setDescription('example description 3');

return [embed1, embed2, embed3];
});
const { PaginatedMessage } = require('@sapphire/discord.js-utilities');

const embed1 = new EmbedBuilder()
.setColor('#FF0000')
.setDescription('example description 1');

const embed2 = new EmbedBuilder()
.setColor('#00FF00')
.setDescription('example description 2');

const embed3 = new EmbedBuilder()
.setColor('#0000FF')
.setDescription('example description 3');

const paginatedMessage = new PaginatedMessage()
.addPageEmbeds([embed1, embed2, embed3]); // You can add up to 10 embeds

Inherited from​

PaginatedMessage.addPageEmbeds


addPages()​

addPages(pages: PaginatedMessagePage[]): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1115

Add pages to the existing ones. The order given is the order they will be used.

Parameters​

ParameterTypeDescription
pagesPaginatedMessagePage[]The pages to add.

Returns​

this

Inherited from​

PaginatedMessage.addPages


applyFooter()​

protected applyFooter(message: PaginatedMessageMessageOptionsUnion, index: number): PaginatedMessageMessageOptionsUnion

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1673

Applies footer to the last embed of the page

Parameters​

ParameterTypeDescription
messagePaginatedMessageMessageOptionsUnionThe message options
indexnumberThe current index

Returns​

PaginatedMessageMessageOptionsUnion

The message options with the footer applied

Inherited from​

PaginatedMessage.applyFooter


clone()​

clone(): PaginatedMessage

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1400

Clones the current handler into a new instance.

Returns​

PaginatedMessage

Inherited from​

PaginatedMessage.clone


formatItems()​

formatItems(formatter: (item: T, index: number, array: T[]) => any): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:136

Sets a format callback that will be mapped to each embed field in the array of items when the embed is paginated. This should convert each item to a format that is either text itself or can be serialized as text.

Parameters​

ParameterTypeDescription
formatter(item: T, index: number, array: T[]) => anyThe formatter callback to be applied to each embed item

Returns​

PaginatedFieldMessageEmbed<T>

Example​

import { PaginatedFieldMessageEmbed } from '@sapphire/discord.js-utilities';

new PaginatedFieldMessageEmbed()
.setTitleField('Test field')
.setTemplate({ embed })
.setItems([
{ title: 'Sapphire Framework', value: 'discord.js Framework' },
{ title: 'Sapphire Framework 2', value: 'discord.js Framework 2' },
{ title: 'Sapphire Framework 3', value: 'discord.js Framework 3' }
])
.formatItems((item) => `${item.title}\n${item.value}`)
.make()
.run(message);

generatePages()​

private generatePages(): void

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:177

Generates the pages for the paginated field message embed. Each page contains a cloned template with modified fields and data.

Returns​

void


getPageOptions()​

getPageOptions(index: number): Promise<undefined | PaginatedMessageMessageOptionsUnion>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1413

Get the options of a page.

Parameters​

ParameterTypeDescription
indexnumberThe index of the page.

Returns​

Promise<undefined | PaginatedMessageMessageOptionsUnion>

Inherited from​

PaginatedMessage.getPageOptions


handleActionLoad()​

protected handleActionLoad(actions: PaginatedMessageAction[], messageOrInteraction: Message<boolean> | AnyInteractableInteraction, targetUser: User): Promise<MessageActionRowComponentBuilder[]>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1527

Handles the loading of actions.

Parameters​

ParameterTypeDescription
actionsPaginatedMessageAction[]The actions to be loaded.
messageOrInteractionMessage<boolean> | AnyInteractableInteractionThe message or interaction that triggered this PaginatedMessage.
targetUserUserThe user the handler is for.

Returns​

Promise<MessageActionRowComponentBuilder[]>

Inherited from​

PaginatedMessage.handleActionLoad


handleCollect()​

protected handleCollect(targetUser: User, channel: DMChannel | PartialDMChannel | PartialGroupDMChannel | NewsChannel | StageChannel | TextChannel | PublicThreadChannel<boolean> | PrivateThreadChannel | VoiceChannel, interaction: PaginatedMessageInteractionUnion): Promise<void>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1587

Handles the collect event from the collector.

Parameters​

ParameterTypeDescription
targetUserUserThe user the handler is for.
channelDMChannel | PartialDMChannel | PartialGroupDMChannel | NewsChannel | StageChannel | TextChannel | PublicThreadChannel<boolean> | PrivateThreadChannel | VoiceChannelThe channel the handler is running at.
interactionPaginatedMessageInteractionUnionThe button interaction that was received.

Returns​

Promise<void>

Inherited from​

PaginatedMessage.handleCollect


handleEnd()​

protected handleEnd(_: Collection<string, PaginatedMessageInteractionUnion>, reason: PaginatedMessageStopReasons): Promise<void>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1640

Handles the end event from the collector.

Parameters​

ParameterTypeDescription
_Collection<string, PaginatedMessageInteractionUnion>-
reasonPaginatedMessageStopReasonsThe reason for which the collector was ended.

Returns​

Promise<void>

Inherited from​

PaginatedMessage.handleEnd


handlePageLoad()​

protected handlePageLoad(page: PaginatedMessagePage, index: number): Promise<PaginatedMessageMessageOptionsUnion>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1507

Handles the load of a page.

Parameters​

ParameterTypeDescription
pagePaginatedMessagePageThe page to be loaded.
indexnumberThe index of the current page.

Returns​

Promise<PaginatedMessageMessageOptionsUnion>

Inherited from​

PaginatedMessage.handlePageLoad


hasPage()​

hasPage(index: number): boolean

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:725

Checks whether or not the handler has a specific page.

Parameters​

ParameterTypeDescription
indexnumberThe index to check.

Returns​

boolean

Inherited from​

PaginatedMessage.hasPage


make()​

make(): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:163

Build the pages of the given array.

You must call the PaginatedFieldMessageEmbed.make and PaginatedFieldMessageEmbed.run methods last, in that order, for the pagination to work.

Returns​

PaginatedFieldMessageEmbed<T>

Example​

import { PaginatedFieldMessageEmbed } from '@sapphire/discord.js-utilities';

new PaginatedFieldMessageEmbed()
.setTitleField('Test field')
.setTemplate({ embed })
.setItems([
{ title: 'Sapphire Framework', value: 'discord.js Framework' },
{ title: 'Sapphire Framework 2', value: 'discord.js Framework 2' },
{ title: 'Sapphire Framework 3', value: 'discord.js Framework 3' }
])
.formatItems((item) => `${item.title}\n${item.value}`)
.make()
.run(message);

paginateArray()​

private paginateArray(items: T[], currentPage: number, perPageItems: number): T[]

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:201

Paginates an array of items.

Parameters​

ParameterTypeDescription
itemsT[]The array of items to paginate.
currentPagenumberThe current page number.
perPageItemsnumberThe number of items per page.

Returns​

T[]

The paginated array of items.


resolvePage()​

resolvePage(messageOrInteraction: Message<boolean> | AnyInteractableInteraction, target: User, index: number): Promise<PaginatedMessageResolvedPage>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1357

Executed whenever an action is triggered and resolved.

Parameters​

ParameterTypeDescription
messageOrInteractionMessage<boolean> | AnyInteractableInteractionThe message or interaction that triggered this PaginatedMessage.
targetUserThe user who will be able to interact with the buttons of this PaginatedMessage.
indexnumberThe index to resolve.

Returns​

Promise<PaginatedMessageResolvedPage>

Inherited from​

PaginatedMessage.resolvePage


resolvePagesOnRun()​

resolvePagesOnRun(messageOrInteraction: Message<boolean> | AnyInteractableInteraction, target: User): Promise<void>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1345

Executed whenever PaginatedMessage.run is called.

Parameters​

ParameterType
messageOrInteractionMessage<boolean> | AnyInteractableInteraction
targetUser

Returns​

Promise<void>

Inherited from​

PaginatedMessage.resolvePagesOnRun


resolvePaginatedMessageInternationalizationContext()​

protected resolvePaginatedMessageInternationalizationContext(messageOrInteraction: Message<boolean> | AnyInteractableInteraction, targetUser: User): PaginatedMessageInternationalizationContext

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1709

Constructs a PaginatedMessageInternationalizationContext

Parameters​

ParameterTypeDescription
messageOrInteractionMessage<boolean> | AnyInteractableInteractionThe message or interaction for which the PaginatedMessageInternationalizationContext should be resolved.
targetUserUserThe target user for whom this interaction is

Returns​

PaginatedMessageInternationalizationContext

A constructed PaginatedMessageInternationalizationContext

Inherited from​

PaginatedMessage.resolvePaginatedMessageInternationalizationContext


resolveTemplate()​

private resolveTemplate(template: EmbedData | EmbedResolvable | (embed: EmbedBuilder) => EmbedResolvable): APIEmbed

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:212

Resolves the template for the embed.

Parameters​

ParameterTypeDescription
templateEmbedData | EmbedResolvable | (embed: EmbedBuilder) => EmbedResolvableThe template for the embed. It can be an EmbedResolvable, EmbedData, or a function that takes an EmbedBuilder and returns an EmbedResolvable.

Returns​

APIEmbed

The resolved APIEmbed object.


run()​

run(messageOrInteraction: Message<boolean> | AnyInteractableInteraction, target?: User): Promise<PaginatedFieldMessageEmbed<T>>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1236

Executes the PaginatedMessage and sends the pages corresponding with PaginatedMessage.index. The handler will start collecting message component interactions.

Parameters​

ParameterTypeDescription
messageOrInteractionMessage<boolean> | AnyInteractableInteractionThe message or interaction that triggered this PaginatedMessage. Generally this will be the command message or an interaction (either a CommandInteraction, ContextMenuInteraction, or an interaction from PaginatedMessageInteractionUnion), but it can also be another message from your client, i.e. to indicate a loading state.
target?UserThe user who will be able to interact with the buttons of this PaginatedMessage. If messageOrInteraction is an instance of Message then this defaults to Message.author messageOrInteraction.author, and if it is an instance of CommandInteraction then it defaults to CommandInteraction.user messageOrInteraction.user.

Returns​

Promise<PaginatedFieldMessageEmbed<T>>

Remark​

Please note that for PaginatedMessage to work in DMs to your client, you need to add the 'CHANNEL' partial to your client.options.partials. Message based commands can always be used in DMs, whereas Chat Input interactions can only be used in DMs when they are registered globally.

Inherited from​

PaginatedMessage.run


setActions()​

setActions(actions: PaginatedMessageAction[], includeDefaultActions: boolean): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:689

Clears all current actions and sets them. The order given is the order they will be used.

Parameters​

ParameterTypeDefault valueDescription
actionsPaginatedMessageAction[]undefinedThe actions to set. This can be either a Button, Link Button, or Select Menu.
includeDefaultActionsbooleanfalseWhether to merge in the PaginatedMessage.defaultActions when setting the actions. If you set this to true then you do not need to manually add ...PaginatedMessage.defaultActions as seen in the first example. The default value is false for backwards compatibility within the current major version.

Returns​

this

Remark​

You can retrieve the default actions for the regular pagination

Examples​

const display = new PaginatedMessage();

display.setActions([
...PaginatedMessage.defaultActions,
])
const display = new PaginatedMessage();

display.setActions([
{
style: 'PRIMARY',
label: 'My Button',
customId: 'custom_button',
type: ComponentType.Button,
run: (context) => console.log(context)
}
], true);
const display = new PaginatedMessage();

display.setActions([
{
style: 'LINK',
label: 'Sapphire Website',
emoji: '🔷',
url: 'https://sapphirejs.dev',
type: ComponentType.Button
}
], true);
const display = new PaginatedMessage();

display.setActions([
{
customId: 'custom_menu',
type: ComponentType.StringSelect,
run: (context) => console.log(context) // Do something here
}
], true);

Remark​

You can add custom Message Buttons by providing style, customId, type, run and at least one of label or emoji.

Remark​

You can add custom Message Link Buttons by providing style, url, type, and at least one of label or emoji.

Remark​

You can add custom Select Menus by providing customId, type, and run.

Inherited from​

PaginatedMessage.setActions


setEmitPartialDMChannelWarning()​

setEmitPartialDMChannelWarning(emitPartialDMChannelWarning: boolean): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:591

Sets the PaginatedMessage.emitPartialDMChannelWarning for this instance of PaginatedMessage. This will only apply to this one instance and no others.

Parameters​

ParameterTypeDescription
emitPartialDMChannelWarningbooleanThe new emitPartialDMChannelWarning to set

Returns​

this

The current instance of PaginatedMessage

Inherited from​

PaginatedMessage.setEmitPartialDMChannelWarning


setIdle()​

setIdle(idle: number): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:609

Sets the amount of time to idle before the paginator is closed.

Parameters​

ParameterTypeDescription
idlenumberThe number to set the idle to.

Returns​

this

Inherited from​

PaginatedMessage.setIdle


setIndex()​

setIndex(index: number): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:600

Sets the handler's current page/message index.

Parameters​

ParameterTypeDescription
indexnumberThe number to set the index to.

Returns​

this

Inherited from​

PaginatedMessage.setIndex


setItems()​

setItems(items: T[]): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:67

Set the items to paginate.

Parameters​

ParameterTypeDescription
itemsT[]The pages to set

Returns​

PaginatedFieldMessageEmbed<T>


setItemsPerPage()​

setItemsPerPage(itemsPerPage: number): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:85

Sets the amount of items that should be shown per page.

Parameters​

ParameterTypeDescription
itemsPerPagenumberThe number of items

Returns​

PaginatedFieldMessageEmbed<T>


setPageActions()​

setPageActions(actions: PaginatedMessageAction[], index: number): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1151

Clear all actions for a page and set the new ones.

Parameters​

ParameterTypeDescription
actionsPaginatedMessageAction[]The actions to set.
indexnumberThe index of the page to set the actions to. This is 0-based.

Returns​

this

Remark​

Internally we check if the provided index exists. This means that calling this function before calling any of the methods below this will not work as the amount of pages will always be 0, thus the index will always be out of bounds. That said, make sure you first define your pages and then define your actions for those pages.

Remark​

Add a select menu to the first page, while preserving all default actions:

Example​

const display = new PaginatedMessage();

display.setPageActions([
{
customId: 'custom_menu',
type: ComponentType.StringSelect,
run: (context) => console.log(context) // Do something here
}
], 0);

See​

PaginatedMessage.setActions for more examples on how to structure the action.

Inherited from​

PaginatedMessage.setPageActions


setPages()​

setPages(pages: PaginatedMessagePage[]): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:733

Clears all current pages and messages and sets them. The order given is the order they will be used.

Parameters​

ParameterTypeDescription
pagesPaginatedMessagePage[]The pages to set.

Returns​

PaginatedFieldMessageEmbed<T>

Inherited from​

PaginatedMessage.setPages


setSelectMenuOptions()​

setSelectMenuOptions(newOptions: PaginatedMessageSelectMenuOptionsFunction): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:543

Sets the PaginatedMessage.selectMenuOptions for this instance of PaginatedMessage. This will only apply to this one instance and no others.

Parameters​

ParameterTypeDescription
newOptionsPaginatedMessageSelectMenuOptionsFunctionThe new options generator to set

Returns​

this

The current instance of PaginatedMessage

Inherited from​

PaginatedMessage.setSelectMenuOptions


setSelectMenuPlaceholder()​

setSelectMenuPlaceholder(placeholder: undefined | string): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:558

Sets the PaginatedMessage.selectMenuPlaceholder for this instance of PaginatedMessage.

This applies only to the string select menu from the PaginatedMessage.defaultActions that offers "go to page" (we internally check the customId for this)

This will only apply to this one instance and no others.

Parameters​

ParameterTypeDescription
placeholderundefined | stringThe new placeholder to set

Returns​

this

The current instance of PaginatedMessage

Inherited from​

PaginatedMessage.setSelectMenuPlaceholder


setShouldAddFooterToEmbeds()​

setShouldAddFooterToEmbeds(newValue: boolean): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:619

Sets the value of shouldAddFooterToEmbeds property and returns the instance of the class.

Parameters​

ParameterTypeDescription
newValuebooleanThe new value for shouldAddFooterToEmbeds.

Returns​

this

The instance of the class with the updated shouldAddFooterToEmbeds value.

Inherited from​

PaginatedMessage.setShouldAddFooterToEmbeds


setStopPaginatedMessageCustomIds()​

setStopPaginatedMessageCustomIds(stopPaginatedMessageCustomIds: string[]): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:580

Sets the PaginatedMessage.stopPaginatedMessageCustomIds for this instance of PaginatedMessage. This will only apply to this one instance and no others.

Parameters​

ParameterTypeDescription
stopPaginatedMessageCustomIdsstring[]The new stopPaginatedMessageCustomIds to set

Returns​

this

The current instance of PaginatedMessage

Inherited from​

PaginatedMessage.setStopPaginatedMessageCustomIds


setTemplate()​

setTemplate(template: EmbedData | EmbedResolvable | (embed: EmbedBuilder) => EmbedResolvable): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:110

Sets the template to be used to display the embed fields as pages. This template can either be set from a template EmbedBuilder instance or an object with embed options.

Parameters​

ParameterTypeDescription
templateEmbedData | EmbedResolvable | (embed: EmbedBuilder) => EmbedResolvableEmbedBuilder

Returns​

PaginatedFieldMessageEmbed<T>

Examples​

import { PaginatedFieldMessageEmbed } from '@sapphire/discord.js-utilities';
import { EmbedBuilder } from 'discord.js';

new PaginatedFieldMessageEmbed().setTemplate(new EmbedBuilder().setTitle('Test pager embed')).make().run(message);
import { PaginatedFieldMessageEmbed } from '@sapphire/discord.js-utilities';

new PaginatedFieldMessageEmbed().setTemplate({ title: 'Test pager embed' }).make().run(message);

setTitleField()​

setTitleField(title: string): PaginatedFieldMessageEmbed<T>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedFieldMessageEmbed.ts:76

Set the title of the embed field that will be used to paginate the items.

Parameters​

ParameterTypeDescription
titlestringThe field title

Returns​

PaginatedFieldMessageEmbed<T>


setUpCollector()​

protected setUpCollector(messageOrInteraction: Message<boolean> | AnyInteractableInteraction, targetUser: User): void

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1465

Sets up the message's collector.

Parameters​

ParameterTypeDescription
messageOrInteractionMessage<boolean> | AnyInteractableInteractionThe message or interaction that triggered this PaginatedMessage.
targetUserUserThe user the handler is for.

Returns​

void

Inherited from​

PaginatedMessage.setUpCollector


setUpMessage()​

protected setUpMessage(messageOrInteraction: Message<boolean> | AnyInteractableInteraction): Promise<void>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:1426

Sets up the message.

Parameters​

ParameterTypeDescription
messageOrInteractionMessage<boolean> | AnyInteractableInteractionThe message or interaction that triggered this PaginatedMessage. Generally this will be the command message or an interaction (either a CommandInteraction, ContextMenuInteraction, or an interaction from PaginatedMessageInteractionUnion), but it can also be another message from your client, i.e. to indicate a loading state.

Returns​

Promise<void>

Inherited from​

PaginatedMessage.setUpMessage


setWrongUserInteractionReply()​

setWrongUserInteractionReply(wrongUserInteractionReply: PaginatedMessageWrongUserInteractionReplyFunction): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:569

Sets the PaginatedMessage.wrongUserInteractionReply for this instance of PaginatedMessage. This will only apply to this one instance and no others.

Parameters​

ParameterTypeDescription
wrongUserInteractionReplyPaginatedMessageWrongUserInteractionReplyFunctionThe new wrongUserInteractionReply to set

Returns​

this

The current instance of PaginatedMessage

Inherited from​

PaginatedMessage.setWrongUserInteractionReply


updateCurrentPage()​

updateCurrentPage(page: PaginatedMessagePage): Promise<PaginatedFieldMessageEmbed<T>>

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/PaginatedMessages/PaginatedMessage.ts:779

Update the current page.

Parameters​

ParameterTypeDescription
pagePaginatedMessagePageThe content to update the page with.

Returns​

Promise<PaginatedFieldMessageEmbed<T>>

Remark​

This method can only be used after PaginatedMessage.run has been used.

Inherited from​

PaginatedMessage.updateCurrentPage