add/remove role to/from users with specific role

!
5 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Violet
Violet12mo ago
hey guys , im trying to add / remove role to/from users with a specific role. honestly im not getting any error , and it was working like a bit ago but suddenly it just stopped working. here is my code https://sourceb.in/RoAJOkCIu4 and when i use
console.log(Role.size);
console.log(Role.size);
it returns 0 , althou i can see some users that has the role
duck
duck12mo ago
<Role>.members only contains cached GuildMembers you'd need to fetch all members first with <Guild>.members.fetch() you only need to do this once, since the cache will be further updated by events
Violet
Violet12mo ago
so if i need to do it once , its better i do it in ready event when the bot is getting online ?
duck
duck12mo ago
sure