I'm unable to retrieve from my reactions.json the emoji name to match the role.name. Not sure what I'm missing and I've been staring at it for hours. '
A bit confused as to what i'm missing here.
reactions.json
{
"channel": "test",
"channelID": "",
"roles": {
"melee": "🪓 Melee DPS",
"ranged": "🏹 Ranged DPS",
"caster": "🧙🏻 Caster DPS",
"healer": "🚑 Healer",
"tank": "🔰 Tank"
},
"vote": {
"melee": "🪓",
"ranged": "🏹",
"caster": "🧙🏻",
"healer": "🚑",
"beginner": "🔰"
},
}
Javascript
client.on('messageReactionAdd', addRole);
async function addRole({message, emojis}, user) {
if (message.partial) {
try {
await message.fetch();
} catch (err) {
console.error('Error fetching message', err);
return;
}
}
const { guild } = message;
const member = guild.members.cache.get(user.id);
const reactionsJSON = JSON.parse(fs.readFileSync('reactions.json', 'utf8'));
const { guild } = message;
const role = guild.roles.cache.find((role) => role.name === reactionsJSON[emojis.name]);
if (!role) {
console.error(`Role not found for '${reactionsJSON[emojis]}'`);
return;
}
try {
member.roles.add(role.id);
} catch (err) {
console.error('Error adding role', err);
return;
}
}
roleoremojis?