PermissionOverwrites question.

I want to deny viewing access for a specific channel (that already has specific viewing permissions (for set to it) to everyone, but also be able to easily revert them. What should I pay attention to to avoid possibly overwriting permissions for that channel? I know I need the PermissionOverwrites to do this to set a deny on everyone, but if I then set an allow later, does that overwrite the existing permissions?
12 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Magikaas
MagikaasOP4mo ago
Discord.js 14.15.3 (as in tag) Node v20.12.0
Fede
Fede4mo ago
A couple hours ago I asked this to chat gpt and it got me this:
channel.permissionOverwrites.edit(
channel.guild.id, //this means everyone, but could be a role too
{ ViewMessages: false }
)
channel.permissionOverwrites.edit(
channel.guild.id, //this means everyone, but could be a role too
{ ViewMessages: false }
)
It's different when the permissions is set at the time the channel is created, but you probably knows this better than me. I had to ask gpt I also don't know if there is .add or .remove IG there is
Fede
Fede4mo ago
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Fede
Fede4mo ago
Nvm
Magikaas
MagikaasOP4mo ago
?
Fede
Fede4mo ago
You could check the docs or try asking chat gpt, this should be an easy thing
Magikaas
MagikaasOP4mo ago
I have checked the docs, I am asking about something that is in the Docs, about PermissionOverwrites I'm not asking ChatGPT about code. I'm asking someone that has actually used discord.js to help explain what I'm trying to do. I also initially wrote something like this after some research, but I want to avoid making mistakes like overwriting existing permissions, I couldn't find anything specific about it.
Mark
Mark4mo ago
PermissionOverwriteManager#edit will only change the selected member/role's overwrite to what you specify. using set will essentially remove all overwrites and then set it to what you provide if you're talking about adding or removing a permission from an existing overwrite, then you would get the current overwrite and modify that, then pass it to edit
Magikaas
MagikaasOP4mo ago
Ahh, thank you. That's a good thing to keep in mind. I appreciate it 🙂
Fede
Fede4mo ago
Yeah was gonna say that
Magikaas
MagikaasOP4mo ago
Thanks, chatgpt 👍 I'll go with a get, change and edit, in that case. Appreciate the explanation!
Want results from more Discord servers?
Add your server