Buttons will not re-enable

I have a pagination system that should disable and enable buttons depending on what page the user is on. The buttons will always stay on their default disabled state and won't change whenever I editReply the message Collector
collector.on('collect', async (button) => {
await button.deferUpdate();
if (button.customId === 'help-v2-previous-page') {
if (pageNumber > -1) {
pageNumber--;
}
}
else if (button.customId === 'help-v2-home') {
pageNumber = -1;
}
else if (button.customId === 'help-v2-next-page') {
if (pageNumber < pages.length - 1) {
pageNumber++;
}
}

// Only doing this because I'm trying to solve the issue
let button1;
let button2;
let button3;
if (pageNumber === -1) {
button1 = true;
button2 = true;
}
else {
button1 = false;
button2 = false;
}

if (pageNumber < pages.length - 1) {
button3 = false;
}
else {
button3 = true;
}

await interaction.editReply({
embeds: [getPageCommandEmbed(pageNumber)],
compontents: [buttonRow(button1, button2, button3)],
});

collector.resetTimer();
});
collector.on('collect', async (button) => {
await button.deferUpdate();
if (button.customId === 'help-v2-previous-page') {
if (pageNumber > -1) {
pageNumber--;
}
}
else if (button.customId === 'help-v2-home') {
pageNumber = -1;
}
else if (button.customId === 'help-v2-next-page') {
if (pageNumber < pages.length - 1) {
pageNumber++;
}
}

// Only doing this because I'm trying to solve the issue
let button1;
let button2;
let button3;
if (pageNumber === -1) {
button1 = true;
button2 = true;
}
else {
button1 = false;
button2 = false;
}

if (pageNumber < pages.length - 1) {
button3 = false;
}
else {
button3 = true;
}

await interaction.editReply({
embeds: [getPageCommandEmbed(pageNumber)],
compontents: [buttonRow(button1, button2, button3)],
});

collector.resetTimer();
});
buttonRow()
const buttonRow = (st1, st2, st3) => {
return new ActionRowBuilder()
.setComponents(prevPage(st1), home(st2), nextPage(st3));
};
const buttonRow = (st1, st2, st3) => {
return new ActionRowBuilder()
.setComponents(prevPage(st1), home(st2), nextPage(st3));
};
button example: prevPage()
const prevPage = (state) => {
return new ButtonBuilder()
.setCustomId('help-v2-previous-page')
.setLabel('Previous Page')
.setEmoji('⬅️')
.setStyle(ButtonStyle.Primary)
.setDisabled(state);
};
const prevPage = (state) => {
return new ButtonBuilder()
.setCustomId('help-v2-previous-page')
.setLabel('Previous Page')
.setEmoji('⬅️')
.setStyle(ButtonStyle.Primary)
.setDisabled(state);
};
3 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
PAdventures
PAdventuresOP15mo ago
great. right.
Want results from more Discord servers?
Add your server