PaginatedMessageEmbedFields empty array

So im kinda confused with the docs and im always getting empty array's when im trying to setItems over an array. i logged already my output from the array and its just an double Object (as it should be afaik) when im accessing the content inside that Object i get my Output as i wanted it but for some reason the PaginatedMessageEmbed can't access it... am i missing something? Thats some of my code:

const botInfoEmbedFields = [
{ name: 'Bot Name', value: interaction.client.user.username },
{ name: 'Bot Tag', value: interaction.client.user.tag },
{ name: 'Bot ID', value: interaction.client.user.id },
{ name: 'Bot Version', value: botVersion },
{ name: 'Bot Uptime', value: this.getUptime() },
{ name: 'Server Uptime', value: this.getServerUptime() },
{ name: 'Platform', value: os.platform() },
{ name: 'CPU', value: os.cpus()[0].model },
{ name: 'Memory', value: `${(os.totalmem() - os.freemem()) / 1024 / 1024} MB / ${os.totalmem() / 1024 / 1024} MB` },
{ name: 'Hostname', value: os.hostname() }
];

const paginatedFields = new PaginatedMessageEmbedFields()
.setTemplate({ title: 'Bot and System Information', color: '#0099ff' })
.setItems(botInfoEmbedFields)
.setItemsPerPage(5);

const pages = paginatedFields.make();

await interaction.editReply({ embeds: [pages[0]] });

paginatedFields.run(interaction);
}

const botInfoEmbedFields = [
{ name: 'Bot Name', value: interaction.client.user.username },
{ name: 'Bot Tag', value: interaction.client.user.tag },
{ name: 'Bot ID', value: interaction.client.user.id },
{ name: 'Bot Version', value: botVersion },
{ name: 'Bot Uptime', value: this.getUptime() },
{ name: 'Server Uptime', value: this.getServerUptime() },
{ name: 'Platform', value: os.platform() },
{ name: 'CPU', value: os.cpus()[0].model },
{ name: 'Memory', value: `${(os.totalmem() - os.freemem()) / 1024 / 1024} MB / ${os.totalmem() / 1024 / 1024} MB` },
{ name: 'Hostname', value: os.hostname() }
];

const paginatedFields = new PaginatedMessageEmbedFields()
.setTemplate({ title: 'Bot and System Information', color: '#0099ff' })
.setItems(botInfoEmbedFields)
.setItemsPerPage(5);

const pages = paginatedFields.make();

await interaction.editReply({ embeds: [pages[0]] });

paginatedFields.run(interaction);
}
Thats the error :
Error processing command: Error: The items array is empty.
at _PaginatedMessageEmbedFields.make (/node_modules/@sapphire/discord.js-utilities/dist/esm/index.mjs:2452:13)
at BotInfoCommand.chatInputRun (/src/commands/Utility/botinfo.js?d=1706863810259&name=botinfo&extension=.js:47:47)
at async /node_modules/@sapphire/framework/dist/esm/listeners/application-commands/chat-input/CoreChatInputCommandAccepted.mjs:17:23
at async Object.fromAsync (d/node_modules/@sapphire/result/dist/esm/index.mjs:617:22)
at async _CoreListener.run (/node_modules/@sapphire/framework/dist/esm/listeners/application-commands/chat-input/CoreChatInputCommandAccepted.mjs:14:20)
at async Object.fromAsync (/node_modules/@sapphire/result/dist/esm/index.mjs:617:22)
at async _CoreListener._run (/node_modules/@sapphire/framework/dist/esm/lib/structures/Listener.mjs:24:20)
Error processing command: Error: The items array is empty.
at _PaginatedMessageEmbedFields.make (/node_modules/@sapphire/discord.js-utilities/dist/esm/index.mjs:2452:13)
at BotInfoCommand.chatInputRun (/src/commands/Utility/botinfo.js?d=1706863810259&name=botinfo&extension=.js:47:47)
at async /node_modules/@sapphire/framework/dist/esm/listeners/application-commands/chat-input/CoreChatInputCommandAccepted.mjs:17:23
at async Object.fromAsync (d/node_modules/@sapphire/result/dist/esm/index.mjs:617:22)
at async _CoreListener.run (/node_modules/@sapphire/framework/dist/esm/listeners/application-commands/chat-input/CoreChatInputCommandAccepted.mjs:14:20)
at async Object.fromAsync (/node_modules/@sapphire/result/dist/esm/index.mjs:617:22)
at async _CoreListener._run (/node_modules/@sapphire/framework/dist/esm/lib/structures/Listener.mjs:24:20)
And thats when i log just one Object in the array and the full array:
2024-02-02 09:50:16 - INFO - Bot Name: CSL Project
2024-02-02 09:50:16 - INFO - [
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object]
2024-02-02 09:50:16 - INFO - ]
2024-02-02 09:50:16 - INFO - Bot Name: CSL Project
2024-02-02 09:50:16 - INFO - [
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object],
2024-02-02 09:50:16 - INFO - [Object], [Object]
2024-02-02 09:50:16 - INFO - ]
Maybe im just missing something or misread the docs :dummy:
Solution:
You're assigning the result of .make() to a different variable and then you call the original object's run. Change the last line to pages.run(interaction) or dont assign it to a different variable.
Jump to solution
1 Reply
Solution
Favna
Favna9mo ago
You're assigning the result of .make() to a different variable and then you call the original object's run. Change the last line to pages.run(interaction) or dont assign it to a different variable.
Want results from more Discord servers?
Add your server