get member role cache crash

TypeError: Cannot read properties of undefined (reading 'id') at get cache [as cache] all I'm doing is accessing the member role cache, and it crashes, because there's no @everyone role? to get an id from? attached is screenshot of src/managers/GuildMemberRoleManager.js:37:101) at the error
4 Replies
d.js toolkit
d.js toolkitā€¢2y 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.
chmod
chmodā€¢2y ago
no
duck
duckā€¢2y ago
are you customizing or otherwise modifying the cache in any way? care to share your client constructor? I can't imagine you don't have the Guilds intent if you have access to a GuildMember object, but could you ensure that you do anyways?
chmod
chmodā€¢2y ago
yup just solved it
const guildRoles = guild.roles.cache;
guildRoles.delete(guild.roles.everyone?.id);
const guildRoles = guild.roles.cache;
guildRoles.delete(guild.roles.everyone?.id);
Forgot to .clone()
const guildRoles = guild.roles.cache.clone();
const guildRoles = guild.roles.cache.clone();
you were 100% correct
Want results from more Discord servers?
Add your server