0
votes

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

1 Answers

1
votes

Your second try is correct, but you're passing guild.member as the user, but that's not a GuildMember (it's undefined). Because, that property doesn't exists.
Try passing a UserResolvable type object: <Message>.author, <Message>.member.

message.guild.channels.find('name', 'loups-garous')
.overwritePermissions(UserResolvable, { // Pass 'UserResolvable' type thing as described in Wiki!
  VIEW_CHANNEL: true,
  SEND_MESSAGES: true,
  READ_MESSAGE_HISTORY: true,
  ATTACH_FILES: false
});