"reaction role by id discord.js" Code Answer's

You're definitely familiar with the best coding language Javascript that developers use to develop their projects and they get all their queries like "reaction role by id discord.js" answered properly. Developers are finding an appropriate answer about reaction role by id discord.js related to the Javascript coding language. By visiting this online portal developers get answers concerning Javascript codes question like reaction role by id discord.js. Enter your desired code related query in the search bar and get every piece of information about Javascript code related question on reaction role by id discord.js. 

reaction role by id discord.js

By Relieved ReindeerRelieved Reindeer on Jan 15, 2021
const Discord = require('discord.js');
const client = new Discord.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 partial
        try {
            await reaction.fetch(); //fetches reaction because not every reaction is stored in the cache
        } catch (error) {
            console.error('Fetching message failed: ', error);
            return;
        }
    }
    if (!user.bot) {
        if (reaction.emoji.id == yourEmojID) { //if the user reacted with the right emoji

            const 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 variable

            const 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

        }
    }
})

Add Comment

2

All those coders who are working on the Javascript based application and are stuck on reaction role by id discord.js can get a collection of related answers to their query. Programmers need to enter their query on reaction role by id discord.js related to Javascript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about reaction role by id discord.js for the programmers working on Javascript code while coding their module. Coders are also allowed to rectify already present answers of reaction role by id discord.js while working on the Javascript language code. Developers can add up suggestions if they deem fit any other answer relating to "reaction role by id discord.js". Visit this developer's friendly online web community, CodeProZone, and get your queries like reaction role by id discord.js resolved professionally and stay updated to the latest Javascript updates. 

Javascript answers related to "reaction role by id discord.js"

View All Javascript queries

Javascript queries related to "reaction role by id discord.js"

Browse Other Code Languages

CodeProZone