Embed and console desync

Hello. Im trying to make a reaction role like system for my server. On startup it sends an embed on the selected channel. In the embed it shows who has role. Below the Embeds are buttons that redeem the role. when the button is pressed, it redeems but the embed does not update. I do not receive an err. Clicking it again, it updates and then doesnt work anymore https://cdn.discordapp.com/attachments/1224214387833835622/1224222029104807966/2024-03-30_19-21-27.mkv?ex=661cb49c&is=660a3f9c&hm=cf06a604a211b3b3a9f51f52a9f0b6dc48894964e472e10fcbf658dc2689e587&
11 Replies
d.js toolkit
d.js toolkit9mo 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!
awdev
awdevOP9mo ago
1. Djs: 14.14.1 Node: 20.8.0 Code:
awdev
awdevOP9mo ago
Syjalo
Syjalo9mo ago
You have an old deprecated version of discord.js. I'm not sure if it will fix your issue, but you should update npm i discord.js@latest
awdev
awdevOP9mo ago
Hmmm well when I updated yesterday that’s what is got… Oops I typed 4 instead of 14
Chrissy
Chrissy9mo ago
add logs to your if statement:
if (member.roles.cache.has(role.id)) {
console.log("adding role")
await member.roles.remove(role);
} else {
console.log("removing role")
await member.roles.add(role);
}
if (member.roles.cache.has(role.id)) {
console.log("adding role")
await member.roles.remove(role);
} else {
console.log("removing role")
await member.roles.add(role);
}
`
awdev
awdevOP9mo ago
ok done and it indicated correctly But the embed doesn’t seem to update still @Chrissy
Chrissy
Chrissy9mo ago
Wait does the embed just not update or the roles not?
awdev
awdevOP9mo ago
roles update embeds dont
Chrissy
Chrissy9mo ago
it could be that roles.members is not valid I'd recommend to call the updateMembersRoles Function through the interaction and get the members like that: // for every role: guild.members.cache. filter(member => member.roles.cache.has(roleId).map(member => member.toString());
awdev
awdevOP9mo ago
its like that kinda but also the embed updates sometime every 2 clicks Huh that doesn’t work either its valid but no updating
Want results from more Discord servers?
Add your server