1
votes

I believe that I had a working line before that would check for a users role called Motion Design and then if they had it continue but if they didnt have it send a message to a channel. It always seems to send the message to the channel even if they have the role. The ****** is the line that should be checking for the role.

I have tried renaming the role and changing in the code but nothing is working.

if (messageReaction.emoji.name === reactions.success) {




        let client1 = messageReaction.users

        const notbot = messageReaction.users.filter(clientuser => clientuser !== client.user).first();
        await messageReaction.remove(notbot);  
            //check if they have role id
********        if(!message.member.roles.find(r => r.name === "Motion Design")) return client.channels.get(`${ticketchat}`).send(`${notbot} You do not have the requested role for that ticket`);

        const defbot = messageReaction.users.filter(clientuser => clientuser == client.user).first();
        await messageReaction.remove(defbot); 


        let web1 = new Discord.RichEmbed()
        .setDescription(`This commission has been claimed by ${notbot} .`)
        .setColor("#15f153")
        .addField("Client", `${message.author} with ID: ${message.author.id}`)
        .addField("Budget", `${budget}`)
        .addField("Time", message.createdAt)
        .addField("Budget", `${budget}`)
        .addField("Requested Freelancer",`<@&${motionDesign}>`)

        let tickets = message.guild.channels.find('name', "tickets")
        if(!tickets) return message.channel.send(`${message.author} Can't find tickets channel.`)
        message.delete().catch(O_o=>{});

        message.author.send(`Freelancer ${notbot} has taken your ticket. ${message.author}`);
2

2 Answers

0
votes

You should use !message.member.roles.get(ROLE_ID), so it doesn't break if you ever decide to change the role name. This is also more reliable. If you still want to use the role name, you don't need that arrow function, you can just do !message.member.roles.find('name', ROLE_NAME)

0
votes

You may use this at *********:

if(!message.member.roles.has("ROLE_ID"))

But if you still want to get the role by its name:

if(!message.member.roles.has(message.guild.roles.find(r => r.name === "ROLE_NAME"))