How to overwrite permissions in node.js with a Discord Bot

Multi tool use
How to overwrite permissions in node.js with a Discord Bot
I have code a Discord Bot, with Node.js, and I want, with the code of my bot, assign a permission for a player
For explain a little more details, I try to create the board game "Werewolves", for playing with my friend on Discord. I develloped this bot (with node.js ; I'm a beginner), allowing, when I enter a command on Discord, to send a message to a player for saying his role in the game.
But I'm blocking in something now : for example for players who are "Werewolves", I want to give her an access to a channel, so that they can talk together, and the others players can't view the messages (I can make that with "roles", but when somebody check the role of an another player, he can view his role ; eand I don't think there is something to don't see roles of a player)
I have check the library discord.js, and I view two solutions ; but I can't get both to work !
The first : (the constant "lg" is for Werewolves ; loup-garou in french ^^)
.then(function(member) {
let lg = new Discord.Permissions(member, 0x00000400)
})
The second "solution" :
.overwritePermissions(guild.member {
'VIEW_CHANNEL': true
'SEND_MESSAGES': true
'READ_MESSAGE_HISTORY': true
})
I repeat, but I have already explained above; I'm trying to get, the fact that the player has a new "role" (but that is not a role I want to add to him), to assign him the permissions for he can see a special channel (Werewolf-channel if he's a werewolf in the game), and he can send a message on that same channel
Here is a screen (https://prnt.sc/k5qvvb): with the arrow, it is the place where the user should have his name (here for example it's my account ^^), and in yellow the permissions he should have (putting others in "false" is obviously not required)
I get no error, the console doesn't show anything abnormal... But the bot doesn't do what I want ^^
Thanks for your help :)
Oxzir
PS : i'm french, so sorry if my english isn't sooo good ^^
1 Answer
1
Try with the master
version of TextChannel.overwritePermissions()
:
master
TextChannel.overwritePermissions()
channel.overwritePermissions({ //pass an object
overwrites: [ //object.overwrites is an array of PermissionOverwriteOptions objects
{
id: "user_id", //options.id is the user id
allowed: ['ALLOWED PERM 1', 'ALLOWED PERM 2', '...'], //options.allowed is an array of permissions you want to be set to true
denied: ['DENIED PERM 1', 'DENIED PERM 2', '...'] //options.denied ... to false
}
]
});
Let me know if this works! If so, remember that the docs page can display the stable
branch, but it can be useful to switch to the master
;)
stable
master
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.