checking if a user has a role in discord js

let allowedRole = message.guild.roles.find("name", "rolename");
    if (message.member.roles.has(allowedRole.id) {
        // allowed access to command
    } else {
       // not allowed access
    })
   

4.33
3
Hedied4unme 105 points

                                    //other code
else if (command === "addquote" && arg) {
    let adminRole = message.guild.roles.find("name", "Admin");
    let modRole = message.guild.roles.find("name", "Mod");

    if(message.member.roles.has(adminRole) || message.member.roles.has(modRole)){
        const hasArr = arr.some((el) => {
            return el.toLowerCase().replace(/\s/g, '') === arg.toLowerCase().replace(/\s/g, '');
        });

        if(hasArr){
            message.channel.send(arg.replace(/\s+/g,' ').trim() + " is already a Quote");
        } else {
            fs.appendFileSync('./Quotes.txt', '\r\n' + arg);
            message.channel.send("Quote added: " + arg);
            arr.push(arg);            
        }   
    }
}

4.33 (3 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
Check if user has role discord js check tagged member has role discord.js if tagged person has role discord.js check if memeber has role discord js check a user has specific role discord.js how to check if a role has a permission discord js check if member has role in discord js how to check a users roles discordjs check if person has a specific role discord.js check if user has roles discordjs discord js check every user with role discord js check every user for role discord js if user got role how to see if somone has a role discord.js guide discord.js check if user has role nodejs discord.js check if user has role noejs how to check if someone has a role in discord.js check if user has roles discord.js discordjs if has role id discord js check if user has role with mention discord.js role check discord js if user has role id discord js check if bot can apply role check if a guild has that role discord js how to check if a message author has a role discord js discord.js how to check if a user has a role has role discord.js check if a mentioned user has a role discord js check if a mentioned user has a role discordjs code example check if mention has a role discord.js discord js check if user has role by id check if message has role mention discord js check if mentioned role discord js check role in discord.js check if user has a role discord.js id check if user has role discord.js id discord.js v12 check if user has role check if user have one role discord.js discord.js check if role exists check member roles discord.js check if user has role by name discordjs check the role member id discord.js check who user added role discord.js discord js if user has role discord js if use has role check if mentioned user has role discord.js check if taged user has role discord.js check if user id has role discord.js discord how to check if user has role node.js discord how to check if user has role check if someonse has a role Discord.js how to check if user has any role discord.js check if user has role discordjs discord js if role is discordjs if role is has role in discord.js discord.js if user has role iud discord.js check if user get role discord.js check if user got role check if someone adds role discord.js see if member has role discordjs check if user who reacts has certain role discordjs check if user has certain role discordjs discord js check if user has a role discord.js has role Check if a user has a role discor.js how to check if a user has a role in discord.js v12 check if user has a role discord.js discord.js check if role is admin discord js if a user has a role check if a member has a role discord.js check roles discord.js check if role exists discord.js check if role exist discord.js how to check how many roles a user has in diiscord.js check if author hasd that role then in discord.js check if author have a specific role discordjs if a member has this role do this discord.js discord js check if role exists check if user got roles discord.js how to check if user has role discord js discord js, check if a user has a role discord js, check if user has a specific role check if member has role by reaction discord.js check roles of user with id discord.js discord bot check if user has role check if player has role discord.js check if role exists discord js check if user has specific rolen discord.js check every role in discord.js how to check if a id is a role discord.js discord js check if user has role in another server discord js check if someone has role in other server discord js check if someone has role in other discord server how to check if a user has a role in discord.js how to check what roles a member has discord.js discord.js user has role check id person has role in discord.js discord.js check if user has a role discord js if player has role user has role discordjs if user has role or is user id discord.js how to tell if a user has a role discord.js v12 how to tell if a user has a role discord.js check is the user has a role discord.js how to check if a role exists on a discord server js check if a user has a praticular role discord.js check if member has role discord.js v12 how to see if a user has a role or not discord.js check role with id discord js discord.js check if user has role id discord.js see if a user has a role if user has role discord js check if user has roles discord.js v12 if member role discord js check if user has discord role js discord.js check user role discord.js check if someone has a role discord.js verify role check if a mentioned user has a role discordjs how to check if a user has a role out of many roles discord.js how to check mention roles discord.js how to check mentioned roles discord.js discord.js 12 check if member has role how to check if user has role discord.js discord.js how to check if author has a specific role check if roles is mentioned discord.js discord.js how to check if a user doesn't have a role if have role discord.js how to check if a user has certain role discord.js How to detect a user's role discord.js Discord.js check role existence check if author has role discord.js discord js has role how to check if member has right roles discord.js discord.js check if user has role v12 how to check if a member has a role discord.js discordjs if userid has role discordjs v12 check if user has role if member has role discord.js discord js how to see if mentioned user has role discord js if mentioned user has role how to see if user has role discord.js with id discord js how to check if mentioned user has role discordjs has role how to detect if a role exists discord js discord.js how to check if message member has role discord.js who has role discord js check role check if someone has a role discord.js check if user have the role with reaction discord.js discord.js test if user has role discord.js check roles discord.js check if user has role how to check all users that have a discord role discord.js check for user role name discord.js check if role exists by id discord.js discord js detect if user has role how to check if a member has certain role discord.js by id how to check if a member ha sdcertain role discord.js discordjs check for role How to check if the user that is mentioned has a specific role discord.js how to check if member has role discord.js discord.js if user has role discord.js if has role discord.js detect if a role is added to a user check if member has role discord.js discord bot how to check if a user has role discordjs check if you have a role discordjs check if user has role check if a user has a role in a specific guild discord.js v12 check everyone who has role discord.js check if a specific user has role discord.js how to see if a user does not have a role discord.js if member has role id discord.js get if member has role discord.js discordjs 12 check if member has role discord js v12 check if user has role check role of mentionned member discord.js how to check if user has role discord.js json check role discord.js check for role discord.js discord check if user has role check if role discord how to check if any member has a role discord.js how to check if someone has 2 roles discord.js how to check is a user has a specific role discord.js check if a user has a role discord.js how to check if a user has a role from an array js discord.js how to see if a user has a role in discord.js message.member.roles how to check if someone has a role discord.js how to check if author has a role discord.js discord.js check persons role discord.py if user has role check if user has a role discord.py How to check if user has role discord.js check if guild has role check if user has role discord.js v12 detect if user have a role discord js detect if user have a role discord j how to check what roles a user has discord.js discord.js how to check what roles a user has check if message author has role discord js get member roles only run command if user has role discord.js check if user has role incl discord.js v12 discord.js check if member has a role how to check how many users have a role discord.js how to check user role ID discord.js check if user has role discoerd.sjs if user has role discord.js discord.js if user has role do else if how to check if a user role in discordjs discord check if member has role how to check when a player has a role discord.jjs check if member has roles discord.js how to check user has roles discord.js doiscord js check if user has certain role how to check if author has a role dj discord memeber has role how to see if a person has a discord role how to check if a person has a role in discord.js checking if a member has a role discor.dkjs checking if a user has a role discord.js checking if the user has an role discord.js check for certain role discord.js check if member role is higher discord.js find member role in discord js how to check if a user has a role discord.js check if user has has a role discord.js how to test if a member has a role discord.js discord js how to know if some1 is staff how to check if a member has a role in discordjs discord.js how to check if someone has a role check if user has role discord.js How to check if the message author has a role discord.js discord.js check if user have role discord.js check role discord js user has role how to check if soeone has a role discord.js V12 discord.js check if guildmember has role how to see if a person has a certain role discord.js 1.12 discord.js check for role discord.js message author has roles js check if user has role discord js how do a see if user has role discord js check user has role discord js check if user has role discord.js check if user has no role discord.js check if member has role discord.js get user roles discordjs find user who on role discord.js check user roles discord.js _roles.has
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source