Martin Lukavec
Martin Lukavec

Reputation: 33

How to set permissions?

I need to set users permissions, i tried

chanel2.overwritePermissions(message.member,{'SEND_MESSAGES': true,'READ_MESSAGES': true})

but it overwrited all permissions (for everyone not just message.member), not just add specific permissions for message.member (but for the 1 member, it does what i need)

Upvotes: 0

Views: 82

Answers (1)

InvincibleM
InvincibleM

Reputation: 519

Its best if you refer to this guide for all of the information you need to know about setting user permissions in a channel. It looks like it is erroring because message.member is not grabbing the user id to set in the overwritePermissions. Ill explain it all here, but next time try adding some error information and context to your question and code :)

You need to make sure that you have a channel object, so you can grab that like so:

const channelID = message.channel.id //alternatively you can hardcode one like so: "588868740980932620"
const channel = message.guild.channels.find(c => {return c.id === channelID})

After you grab the channel object, you can now set the channel permissions like so:

// channel is whatever your constant variable is in the section above
// message.member.user.id is identical to message.author.id
channel.overwritePermissions(message.member.user.id, {
 SEND_MESSAGES: true,
 READ_MESSAGES: true,
 ATTACH_FILES: true
});

You can find permission flags here.

Hopefully, this helps you. DiscordJS Guide and Discord JS Docs are very helpful areas to look for help.

Upvotes: 1

Related Questions