check every role in discord.js code example
Example 1: check member role discordjs 12
if (message.member.roles.find(r => r.name === "ROLE_NAME")) {
}
Example 2: checking if a user has a role in discord js
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);
}
}
}