reaction role by id discord js

Solutions on MaxInterview for reaction role by id discord js by the best coders in the world

showing results for - "reaction role by id discord js"
Jérémie
31 Apr 2019
1const Discord = require('discord.js');
2const 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)
3const prefix = "-";
4
5client.on('messageReactionAdd', async (reaction, user) => {
6    if (reaction.partial) { //this whole section just checks if the reaction is partial
7        try {
8            await reaction.fetch(); //fetches reaction because not every reaction is stored in the cache
9        } catch (error) {
10            console.error('Fetching message failed: ', error);
11            return;
12        }
13    }
14    if (!user.bot) {
15        if (reaction.emoji.id == yourEmojID) { //if the user reacted with the right emoji
16
17            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)
18
19            const { guild } = reaction.message //store the guild of the reaction in variable
20
21            const member = guild.members.cache.find(member => member.id === user.id); //find the member who reacted (because user and member are seperate things)
22
23            member.roles.add(role); //assign selected role to member
24
25        }
26    }
27})
queries leading to this page
how to give a role with reactions discord jsdiscord js on reaction add rolehow to give roles from reactionsdiscord edit rolehow to make a reaction role discord jsreaction roles with discord jsadd role with reaction discord jsreaction role command discord jsdiscord js on reaction rolereaction role discord jsdiscord js add reaction rolediscord js get role on reactiondiscord js reaction roles with buttonsdiscord js message reaction give rolediscord js give role when reacthow to make reaction roles discord jsgive role on react discord jsreaction role discord js v12reaction role system discord jsadd role to user that react discord jsdiscord js 13 reaction roleadd role with reaction discorddiscord assign role based on reactiondiscord reaction roles jsgive a role based of of reactions discord jsdiscord js reaction role adddiscord js give role to reactionreaction role discordjsreaction roles add command discord jsreact to get role discord jsreaction role discord jsdiscord assign role by reactionreaction role discord js codehow to assign roles with reactions discordadd role on react discord jsdiscord js reaction rolesdiscord set role by reactiondiscord js reaction role commandhow to set reaction roles discord discord jshow to make reaction role commands on discord jsget roles of user who reacts to a reaction discordjsreaction roles discord jsassign roles with reactions discordgive role react message discord jsreaction role message id discord jsdiscord js reaction role v12how to get a role with a reaction in discord jsassign role on reaction by id discord jsreact to assign role discordrole reaction discord jsdiscord js add role on reactiondiscord js reaction rolesdiscord add role with reactionhow to make custom reaction roles with discord jsgive role with react discord jsget a role with a reaction in discord jsdiscord js give roles depending on reactionadd roles to reactions discord jsdiscord js v12 give role when reactdiscord bot assign roles with reactionsdiscord js role reactionreactions role discord jsfind role by reaction discord jsdiscordjs new reaction roleadd reaction role by id discord jshow to do reaction role discord jshow to assign roles in discord with reactionsdiscordjs reaction role discord js give role when reactdiscord js reaction role botreaction role bot discord jsgive role by id discord jshow to assign discord roles using reactionsdiscord js reaction rolegive role with reaction discord jsgive role when reaction discord jsdiscord js reaction rolediscord add role to user djsdiscord js reactiom role sreaction role in discord jshow to make reaction roles on discord jsdiscord js react rolediscord js add role on message reactiondiscord js react to rolediscord js add role on reactreaction role by id discord js