T
T
Timezel2021-01-14 13:22:50
Node.js
Timezel, 2021-01-14 13:22:50

When a member of the discord server clicks on an emoji, an error is thrown, but when I click the button everything works, the role is given?

I wrote a code that should give out a role by clicking on an emoji, and it gives out, only to me. When another member of the discord server clicks on an emoji, an error is thrown. Please help!

module.exports = {
    name: 'reactionrole',
    description: "Выдает роль по нажатию по эмоджи",
    async execute(message, args, Discord, client) {
        const channel = '790381294952644628';
        const verificationRole = message.guild.roles.cache.find(role => role.name === "Верификация");

        const verificationEmoji = '✅';

        let embed = new Discord.MessageEmbed()
        .setColor('#00cc66')
        .setTitle('Для прохождения верефикации нажмите на эмодзи снизу')
        .setDescription('Верификация - роль обозначающая игрока на сервере, позволяющая вам видеть текстовые и голосовые каналы нашего дискорда.')
            

        let messageEmbed = await message.channel.send(embed);
        messageEmbed.react(verificationEmoji);

        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.ad == channel) {
                if (reaction.emoji.name === verificationEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.add(verificationRole);
                } 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 == channel) {
                if (reaction.emoji.name === verificationEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(verificationRole);
                } else {
                    return;
                }
            }
            
        });
    }
} >
module.exports = {
    name: 'reactionrole',
    description: "Выдает роль по нажатию по эмоджи",
    async execute(message, args, Discord, client) {
        const channel = '790381294952644628';
        const verificationRole = message.guild.roles.cache.find(role => role.name === "Верификация");

        const verificationEmoji = '✅';

        let embed = new Discord.MessageEmbed()
        .setColor('#00cc66')
        .setTitle('Для прохождения верефикации нажмите на эмодзи снизу')
        .setDescription('Верификация - роль обозначающая игрока на сервере, позволяющая вам видеть текстовые и голосовые каналы нашего дискорда.')
            

        let messageEmbed = await message.channel.send(embed);
        messageEmbed.react(verificationEmoji);

        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.ad == channel) {
                if (reaction.emoji.name === verificationEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.add(verificationRole);
                } 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 == channel) {
                if (reaction.emoji.name === verificationEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(verificationRole);
                } else {
                    return;
                }
            }
            
        });
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wz, 2021-02-07
@rensly

role rights

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question