Paginination limitation when not using select menus

I have the following error being presented to me
(node:1484241) [PAGINATED_MESSAGE_EXCEEDED_MAXIMUM_AMOUNT_OF_PAGES] PaginatedMessageExceededMessagePageAmount: Maximum amount of pages exceeded for PaginatedMessage. Please check your instance of PaginatedMessage and ensure that you do not exceed 25 pages total. If you do need more than 25 pages you can extend the class and overwrite the actions in the constructor.
and this is my current code giving the error:
import { PaginatedMessage } from '@sapphire/discord.js-utilities';
import { EmbedBuilder } from 'discord.js';

export function movieResponseRebuilder(movieResponse: object) {
console.log('movie Response: ', JSON.stringify(movieResponse));

const display = new PaginatedMessage({
template: new EmbedBuilder().setColor('#8E44AD')
});

movieResponse.forEach((movie) => {
display.addPageEmbed((embed) => {
embed //
.addFields({
name: 'Test Name',
value: 'Test value'
});
return embed;
});
console.log('looped movie data', JSON.stringify(movie));
});

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

export function movieResponseRebuilder(movieResponse: object) {
console.log('movie Response: ', JSON.stringify(movieResponse));

const display = new PaginatedMessage({
template: new EmbedBuilder().setColor('#8E44AD')
});

movieResponse.forEach((movie) => {
display.addPageEmbed((embed) => {
embed //
.addFields({
name: 'Test Name',
value: 'Test value'
});
return embed;
});
console.log('looped movie data', JSON.stringify(movie));
});

return display;
}
movieResponse is an array of objects that can exceed 25 objects. how do I get around this error as you can see, I don't have any menus in place in my embed code.
Solution:
Extend the class and override the addPage method. Never forget the basic principles of object oriented programming. You can achieve a lot with simple class extension....
Jump to solution
14 Replies
Solution
Favna
Favna14mo ago
Extend the class and override the addPage method. Never forget the basic principles of object oriented programming. You can achieve a lot with simple class extension.
Caspian Nightworth
Caspian NightworthOP14mo ago
there are some things in OOP i have not done before and this extending a class to override something
Favna
Favna14mo ago
You have because that’s literally what writing commands is
Caspian Nightworth
Caspian NightworthOP14mo ago
i have had examples to work off of
Favna
Favna14mo ago
Learn TypeScript
Extending classes | Learn TypeScript
How a class can extend another class and add additional functionality
Documentation - Classes
How classes work in TypeScript
ChatGPT
A conversational AI system that listens, learns, and challenges
Caspian Nightworth
Caspian NightworthOP14mo ago
chatgpt what will that do? i've not used it before
Favna
Favna14mo ago
Welcome to 2023 where you can ask AI questions and get answers that are relatively good Or use bing.com chat to have free GPT 4.0 Turbo
Caspian Nightworth
Caspian NightworthOP14mo ago
something is missing and i don't know what
No description
Favna
Favna14mo ago
No idea what MessageEmbedLike it but the builder is called EmbedBuilder. ChatGPT GPT3.5-turbo’s data is from 2020 which is why I mentioned bing chat.
Caspian Nightworth
Caspian NightworthOP14mo ago
ai from bing did that is there a maxPages property? also, looking at the responses received back, isn't MessageEmbed from discord.js now EmbedBuilder?
KB
KB14mo ago
Favna just said that Also, you can check the arguments from the original addPageEmbed to see the types.
Seren_Modz 21
Seren_Modz 2114mo ago
the page limit is on the addPage() method, and is hard-coded so there is no maxPages property
Caspian Nightworth
Caspian NightworthOP14mo ago
i'm trying to override the addPage() method and VSCode presents this error to me and I don't know what it means. this is my code
import { PaginatedMessage, PaginatedMessagePage } from '@sapphire/discord.js-utilities';

export class ExtendedPaginatedMessage extends PaginatedMessage {
// Override the addPagemethod to allow for more than 25 pages
public override addPage(page: PaginatedMessagePage): PaginatedMessage {
this.pages.push(page);

return this;
}
}
import { PaginatedMessage, PaginatedMessagePage } from '@sapphire/discord.js-utilities';

export class ExtendedPaginatedMessage extends PaginatedMessage {
// Override the addPagemethod to allow for more than 25 pages
public override addPage(page: PaginatedMessagePage): PaginatedMessage {
this.pages.push(page);

return this;
}
}
No description
Favna
Favna14mo ago
import { PaginatedMessage, PaginatedMessagePage } from '@sapphire/discord.js-utilities';

export class ExtendedPaginatedMessage extends PaginatedMessage {
// Override the addPagemethod to allow for more than 25 pages
public override addPage(page: PaginatedMessagePage): this {
this.pages.push(page);

return this;
}
}
import { PaginatedMessage, PaginatedMessagePage } from '@sapphire/discord.js-utilities';

export class ExtendedPaginatedMessage extends PaginatedMessage {
// Override the addPagemethod to allow for more than 25 pages
public override addPage(page: PaginatedMessagePage): this {
this.pages.push(page);

return this;
}
}
If you carefully read the error it says that the type mismatches and the expected return type is this
Want results from more Discord servers?
Add your server