Answer the question
In order to leave comments, you need to log in
Why after I clicked on the emoji, the role is not issued?
I used the code from this site .
In general, after you add an emoji, the role is not given to the player, and no error appears.
I checked both the emoji id and the channel id and the message itself, but all without errors.
I no longer understand what is happening, the code is correct and there are no errors. Can you help?
module.exports = {
name: 'rearole',
description: "Sets up a reaction role message!",
async execute(message, args, Discord, client) {
const channelID = '814125436698099752';
const EmojiRole = message.guild.roles.cache.find(role => role.name === "ПОДПИСКА");
const EmojiTeam = '<:anicloud:717681818127826964>';
let embed = new Discord.MessageEmbed()
.setColor('#000000')
.setTitle('Оповещение об обновлениях')
.setDescription(`Нажми на эмодзи ${EmojiTeam} чтобы получать оповещения!`);
let messageEmbed = await message.channel.send(embed);
messageEmbed.react(EmojiTeam);
client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channelID) {
if (reaction.emoji.name === EmojiTeam) {
await reaction.message.guild.members.cache.get(user.id).roles.add(EmojiRole);
}
} else {
return;
}
});
client.on('messageReactionRemove', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channelID) {
if (reaction.emoji.name === EmojiTeam) {
await reaction.message.guild.members.cache.get(user.id).roles.remove(EmojiRole);
}
} else {
return;
}
});
}
}
Answer the question
In order to leave comments, you need to log in
You've parenthesized this: if (reaction.emoji.name === "EmojiTeam") {, remove "", variables don't work in "".
Further:
await reaction.message.guild.members.cache.get(user.id).roles.add(EmojiRole);
what is this? await does add(...), not get(). You need to know the syntax. let member = await reaction.message.guild.members.cache.get(user.id);
member.roles.add(EmojiRole);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question