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);
}
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);
}