I have the code below:
collector.on('collect', async (reaction, user) => {
if (!user.bot) {
let role = reaction.message.guild.roles.cache.find((role) => { return role.name === '️announcements-ping' });
console.log(role);
/* let userMember = await reaction.message.guild.members.fetch(user);
userMember.roles.add(role); */
}
});
It's supposed to add the announcements-ping
role to whoever reacts to the message, but when I console log the variable role
it returns undefined.
What am I doing wrong?
Thanks!
announcements-ping
does not exist. It's not recommended to use role names, as they can change rapidly. Instead, userole = reaction.message.guild.roles.cache.find(role => role.id === 'RoleID');
– KifoPL.get()
if you're using an ID – Elitezen