Am I properly checking if the message author has a certain role?

I’ve run into an error. I’m trying to find to find if a user who has done a command has a certain role, when I tested it with the role it would send “You do not have the staff role” even though I did.

const Discord = require('discord.js');

const client = new Discord.Client();

const prefix = 'quest!';

client.once('ready', () => {
    console.log('Bot is online!');
});

const questEmbed = new Discord.MessageEmbed()
    .setTitle('Quest')
    .setColor('#ff0000')
    .addField('Quest"', "Kill the local Orc tribe in the #forest")

client.on('message', message =>{
    if(!message.content.startsWith(prefix) || message.author.bot ) return;

    const args = message.content.slice(prefix.length).split(/ +/);
    const command = args.shift().toLowerCase();

    if (command === 'orct'){
        if(message.member.roles.cache.has(830168053122859058)) {
            message.channel.send(helpEmbed);
          } else {
            message.channel.send("You do not have the staff role!");
          }
    }
});

I’ve read that you had to use message.member.roles.cache so I’ve attempted this with that.

Answer

The collection.has() function requires the parameter of the role, not the role’s id, and also the ID is a string not number. That explains why it isn’t working, but instead of using .has with the role, I’d instead put if(message.member.roles.cache.get("830168053122859058")) {, so effectively its getting the role, and the if statement will always be true (unless the role is not found)