const filter = (i) => i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 });
collector.on('collect', async (i) => {
try {
if (i.user.id !== interaction.user.id) {
// User is not the original user who triggered the command
await i.reply({ content: 'Only the user who triggered the command can use these buttons', ephemeral: true });
return;
}
if (i.customId === 'prev_page') {
if (currentPage > 0) {
currentPage--;
await updateEmbed();
}
} else if (i.customId === 'next_page') {
if (currentPage < totalPages - 1) {
currentPage++;
await updateEmbed();
}
}
// Acknowledge the interaction
await i.deferUpdate();
} catch (error) {
console.error(error);
}
});
collector.on('end', () => {
const disabledButtonRow = createButtonRow(currentPage, totalPages);
disabledButtonRow.components.forEach(button => button.setDisabled(true));
interaction.editReply({ components: [disabledButtonRow] });
});
}
} catch (e) {
const filter = (i) => i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 });
collector.on('collect', async (i) => {
try {
if (i.user.id !== interaction.user.id) {
// User is not the original user who triggered the command
await i.reply({ content: 'Only the user who triggered the command can use these buttons', ephemeral: true });
return;
}
if (i.customId === 'prev_page') {
if (currentPage > 0) {
currentPage--;
await updateEmbed();
}
} else if (i.customId === 'next_page') {
if (currentPage < totalPages - 1) {
currentPage++;
await updateEmbed();
}
}
// Acknowledge the interaction
await i.deferUpdate();
} catch (error) {
console.error(error);
}
});
collector.on('end', () => {
const disabledButtonRow = createButtonRow(currentPage, totalPages);
disabledButtonRow.components.forEach(button => button.setDisabled(true));
interaction.editReply({ components: [disabledButtonRow] });
});
}
} catch (e) {