© 2026 Hedgehog Software, LLC
private async sendMenu(interactionOrMessage: Message | AnyInteractableInteraction) { const radioStations = radioList; // await Radio.findAll(); const chunkSize = 10; const paginatedMessage = new PaginatedMessageEmbedFields() .setActions([]) .setTemplate({ title: 'Radio Stations' }) .setItems( radioStations.map((radioStation) => ({ name: radioStation.name, value: radioStation.url, inline: false })) ) .setItemsPerPage(chunkSize) .make(); for (let i = 0; i < radioStations.length; i += chunkSize) { paginatedMessage.setPageActions( [ { style: ButtonStyle.Primary, label: '◀', customId: 'back-page', type: ComponentType.Button, run: async () => { if (paginatedMessage.hasPage(paginatedMessage.index - 1)) { paginatedMessage.setIndex(paginatedMessage.index - 1); } } }, { style: ButtonStyle.Secondary, label: `${Math.round((i + chunkSize) / chunkSize)}/${Math.round(radioStations.length / chunkSize)}`, customId: 'cur-page', type: ComponentType.Button, disabled: true }, { style: ButtonStyle.Primary, label: '▶', customId: 'next-page', type: ComponentType.Button, run: async () => { if (paginatedMessage.hasPage(paginatedMessage.index + 1)) { paginatedMessage.setIndex(paginatedMessage.index + 1); } } } ], Math.round(i / chunkSize) ); } // paginatedMessage.addAction({ // customId: 'add-radio', // label: 'Placeholder action to escape the error', // style: ButtonStyle.Primary, // type: ComponentType.Button, // disabled: true // }); paginatedMessage.run(interactionOrMessage); }
pnpm add @sapphire/discord.js-utilities@pr-684
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members