'how to set deny permission to role [Discord JS]
so I tried to create a mute role. but I'm confused how to set permission to deny
My Code:
message.guild.roles.create({
data: {
name: "Muted",
color: "#000000",
permissions: ["SEND_MESSAGES"]
},
})
Solution 1:[1]
When creating a role, you can remove or set permissions using setPermissions. Here is a simple example of how to set and remove permissions:
Discord.js^12
// Create role (Assuming 'guild' is the Server Guild)
var guild = message.guild;
guild.roles.create({ data: { name: 'An amazing name!' } }).then(role => {
// Remove all permissions from the role
role.setPermissions(0);
// Set a list of new permissions
role.setPermissions(['SEND_MESSAGES', 'KICK_MEMBERS', 'BAN_MEMBERS']);
}).catch(e => {
// An error occurred while trying to create the role
console.log(e);
});
If you want the user to be unable to write, don't forget to remove SEND_MESSAGES from the permission list. It works best if you configure the new role directly in the channels where you don't want the user to type (with channel permissions.
You can see the list of permissions at: https://discord.js.org/#/docs/discord.js/v12/class/Permissions?scrollTo=s-FLAGS
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
