Ejemplo: asignar rol en la reacción por id discord.js
constDiscord=require('discord.js');const client =newDiscord.Client( partials:['MESSAGE','CHANNEL','REACTION']);//partials arent really needed but I woudld reccomend using them because not every reaction is stored in the cache (it's new in v12)const prefix ="-";
client.on('messageReactionAdd',async(reaction, user)=>if(reaction.partial)//this whole section just checks if the reaction is partialtryawait reaction.fetch();//fetches reaction because not every reaction is stored in the cachecatch(error)console.error('Fetching message failed: ', error);return;if(!user.bot)if(reaction.emoji.id== yourEmojID)//if the user reacted with the right emojiconst role = reaction.message.guild.roles.cache.find(r=> r.id=== yourRoleID);//finds role you want to assign (you could also user .name instead of .id)const guild = reaction.message//store the guild of the reaction in variableconst member = guild.members.cache.find(member=> member.id=== user.id);//find the member who reacted (because user and member are seperate things)
member.roles.add(role);//assign selected role to member)
Recuerda que puedes dar difusión a esta noticia si te fue de ayuda.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)