This repository has been archived on 2024-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
discord.js-rr-bot/Src/Events/Reactions/reactionAdd.js
2022-06-18 23:28:38 -04:00

20 lines
No EOL
824 B
JavaScript

const react = require("../../Functions/mongodb-reaction-role");
module.exports = {
name: "messageReactionAdd",
run: async (reaction, user, client, container) => {
if (user.partial) await user.fetch();
if (reaction.partial) await reaction.fetch();
if (reaction.message.partial) await reaction.message.fetch();
if (user.bot) return;
let rolefetch = await react.fetchrr(client, reaction.message.guild.id, reaction.message.id, reaction.emoji.name);
if (!rolefetch) return;
let member = await reaction.message.guild.members.cache.get(user.id)
if (!member.roles.cache.has(rolefetch.roleid)) {
await member.roles.add(rolefetch.roleid)
console.log(`Role on ${reaction.emoji.name} has been given`)
}
}
}