fix pagination

If the button press the embed would not update https://srcb.in/2C2bR1jTuJ in 1 video I want it to be like the 2nd video
42 Replies
d.js toolkit
d.js toolkit2y 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!
hehebrd !!
hehebrd !!OP2y ago
hehebrd !!
hehebrd !!OP2y ago
Error
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at ButtonInteraction.editReply (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:157:48)
at InteractionCollector.<anonymous> (/home/runner/Discord-Bot-V14/src/interactions/Command/presence5.js:111:15)
at InteractionCollector.emit (node:events:539:35)
at InteractionCollector.handleCollect (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/Collector.js:133:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at ButtonInteraction.editReply (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:157:48)
at InteractionCollector.<anonymous> (/home/runner/Discord-Bot-V14/src/interactions/Command/presence5.js:111:15)
at InteractionCollector.emit (node:events:539:35)
at InteractionCollector.handleCollect (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/Collector.js:133:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
https://srcb.in/2C2bR1jTuJ Here is my code where want to add that
d.js docs
d.js docs2y ago
Tag suggestion for @brdknight: If you are waiting for button or select menu input from a specific message, don't create the collector on the channel. - Channel collectors return component interactions for any component within that channel.
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
const filter = (i) => i.user.id === interaction.user.id && (i.customId === 'prev_page' || i.customId === 'next_page');
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 });
const filter = (i) => i.user.id === interaction.user.id && (i.customId === 'prev_page' || i.customId === 'next_page');
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 60000 });
Is this?
i.deferUpdate();
i.deferUpdate();
The code has only this
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Ok My collecter is ok?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Want to remove.channel? How is it possible
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
W8 i will check
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
W8 this is not that code 1 min https://srcb.in/kiBkAuqEBn This is the code
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at InteractionCollector.<anonymous> (/home/runner/Discord-Bot-V14/src/interactions/Command/presence5.js:129:25)
at InteractionCollector.emit (node:events:539:35)
at InteractionCollector.stop (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/Collector.js:233:10)
at Timeout.<anonymous> (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/Collector.js:96:61)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at InteractionCollector.<anonymous> (/home/runner/Discord-Bot-V14/src/interactions/Command/presence5.js:129:25)
at InteractionCollector.emit (node:events:539:35)
at InteractionCollector.stop (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/Collector.js:233:10)
at Timeout.<anonymous> (/home/runner/Discord-Bot-V14/node_modules/discord.js/src/structures/interfaces/Collector.js:96:61)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
Errors
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Ok w8 1st
await interaction.reply({ embeds: [embed], components: [row] });
await interaction.reply({ embeds: [embed], components: [row] });
Here I want to add
return await interaction.reply({ embeds: [embed], components: [row] });
return await interaction.reply({ embeds: [embed], components: [row] });
Like this?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
TypeError: sendEmbed.createMessageComponentCollector is not a function
at Object.run (/home/runner/Discord-Bot-V14/src/interactions/Command/presence5.js:101:37)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
TypeError: sendEmbed.createMessageComponentCollector is not a function
at Object.run (/home/runner/Discord-Bot-V14/src/interactions/Command/presence5.js:101:37)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error occurs https://srcb.in/jI5CnF5wip Updated the code like u said
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Code It's ok no prblm ❤️
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Which want to change Compenent collecter?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Ok When i press the next button the embed would update and no errors occur on console
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
So what to do Hey @.gwapes are u there
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Can u give the Code @.gwapes heey
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Ok i.update({ embeds: [embed] components: [what should be add on here is it row or anything?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
Components consist buttons https://srcb.in/AXC8rgWnqH Where is problem exists
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
const sendEmbed = async (page, status) => {
const embed = generatePageEmbed(page, status);

const row = new Discord.ActionRowBuilder()
.addComponents(
new Discord.ButtonBuilder()
.setCustomId('prev_page')
.setEmoji(':arrow_left:')
.setStyle(Discord.ButtonStyle.Danger)
.setDisabled(page === 1),
new Discord.ButtonBuilder()
.setCustomId('next_page')
.setEmoji(':arrow_right:')
.setStyle(Discord.ButtonStyle.Success)
.setDisabled(page === totalPages)
);

return await interaction.reply({ embeds: [embed], components: [row] });
};

const msg = await sendEmbed(currentPage, choice);

const filter = (i) => i.user.id === interaction.user.id && (i.customId === 'prev_page' || i.customId === 'next_page');
const collector = msg.createMessageComponentCollector({ filter, time: 60000 });

collector.on('collect', async (i) => {
if (i.customId === 'prev_page' && currentPage > 1) {
currentPage--;
} else if (i.customId === 'next_page' && currentPage < totalPages) {
currentPage++;
}

// return await sendEmbed(currentPage, choice);
i.update()
const sendEmbed = async (page, status) => {
const embed = generatePageEmbed(page, status);

const row = new Discord.ActionRowBuilder()
.addComponents(
new Discord.ButtonBuilder()
.setCustomId('prev_page')
.setEmoji(':arrow_left:')
.setStyle(Discord.ButtonStyle.Danger)
.setDisabled(page === 1),
new Discord.ButtonBuilder()
.setCustomId('next_page')
.setEmoji(':arrow_right:')
.setStyle(Discord.ButtonStyle.Success)
.setDisabled(page === totalPages)
);

return await interaction.reply({ embeds: [embed], components: [row] });
};

const msg = await sendEmbed(currentPage, choice);

const filter = (i) => i.user.id === interaction.user.id && (i.customId === 'prev_page' || i.customId === 'next_page');
const collector = msg.createMessageComponentCollector({ filter, time: 60000 });

collector.on('collect', async (i) => {
if (i.customId === 'prev_page' && currentPage > 1) {
currentPage--;
} else if (i.customId === 'next_page' && currentPage < totalPages) {
currentPage++;
}

// return await sendEmbed(currentPage, choice);
i.update()
Here is buttons interactiom
hehebrd !!
hehebrd !!OP2y ago
hehebrd !!
hehebrd !!OP2y ago
This is my problem Bro it is already updated using i.update();
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
hehebrd !!
hehebrd !!OP2y ago
No errors exist So i want to do the console.log(currentPage)
hehebrd !!
hehebrd !!OP2y ago
hehebrd !!
hehebrd !!OP17mo ago
const newEmbed = generatePageEmbed(currentPage, choice);
msg.edit({ embeds: [newEmbed] });

// return await sendEmbed(currentPage, choice);
i.update()
});
const newEmbed = generatePageEmbed(currentPage, choice);
msg.edit({ embeds: [newEmbed] });

// return await sendEmbed(currentPage, choice);
i.update()
});
The is fixed by this but prev buttons not coming why Hh ok
Want results from more Discord servers?
Add your server