After a working bot for more than 2 years, message.member is now returning null. Not sure why, here is my code:
if(!message.member.roles.has(adminRole.id)) {
return message.reply("You're not an admin, sorry!");
}
getting an error of : " cannot find roles of null "
looked online and solutions were that I need to fetch guild member first?
so would the solution be:
guild.members.fetch()
.then(code here)
?
how are you getting the message? I assume this is not in a message event?
As of today, Discord requires you to have the GUILD_MEMBERS and GUILD_PRESENCES intents specified to get guild members with the initial payload. In v11, Message#member is set as a property instead of a getter, so the message author won't be in the guild's member cache yet. Please update to v12.
just update to v12, as v11 isn't supported anymore and it should work in v12.