javascript - Find out If Someone Has Role Discord.Js -


i made simple quote bot server, admin wants mod+ people able add quotes avoid spam. went documentation , did everything, can't work. here's have:

//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() + " quote");         } else {             fs.appendfilesync('./quotes.txt', '\r\n' + arg);             message.channel.send("quote added: " + arg);             arr.push(arg);                     }        } } 

it's finicky. work if user has mod role, of times wont. if

console.log(message.memeber.roles.has(adminrole)); console.log(message.memeber.roles.has(modrole)); 

both output false, work? honestly, have no idea @ point.

message.member.roles collection. instead of getting roles object, looking it, role directly in collection. try this:

else if (command === "addquote" && arg) {     if(message.member.roles.find("name", "admin") || message.member.roles.find("name", "mod")){         //rest of code     } 

note, role name must name put in find including emojis if there's in role name.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -