role permission discord.js code example
Example 1: permissions discord.js
if (member.hasPermission('KICK_MEMBERS')) {
console.log('This member can kick');
}
if (member.hasPermission(['KICK_MEMBERS', 'BAN_MEMBERS'])) {
console.log('This member can kick and ban');
}
if (member.hasPermission('KICK_MEMBERS', { checkAdmin: false, checkOwner: false })) {
console.log('This member can kick without allowing admin to override');
}
Example 2: discord.js set role permissions for all channels
message.guild.channels.cache.forEach(ch =>
{
if(ch.type == "text")
ch.overwritePermissions([
{
id: muteRole.id,
deny: ['SEND_MESSAGES'],
},
], 'Needed to change permissions');
})