What is the easiest way to edit multiple permissionOverwrites?
So far i have tried <TextChannel>.edit, but this overrides all current permissions.
So i've spread those into an array and then pushed the new overwrites into them, but that brings me to point 2:
this is for a close ticket command, thus the permissions i edit are for the member that created the ticket, and its setting the SendMessages permission to false
Now, if i spread the current permissions, and then add the updated ones, this means the array includes both the current permissions (in which the SendMessages permission is set to true), and the new one, in which it is set to false. Which one of these will override? I assume since the edited ones are the last to be pushed into the array, they will override but i'm unsure
Or am i making things overcomplicated (again) and is there a really easy way to do this that i'm looking over?
25 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-servers.
- Issue solved? Press the button!to visualise: this is how the array would look like
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
yeah that was what i was thinkin too
but just wanna make sure there isnt an easier way that i'm overlooking
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
yeah but thats for a single one, this is for a ticket, which can have multiple members added to them
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
yeah that could be a better idea too. but there's also a set of support roles which are added (and are configurable per guild) which dont need their permission edited.
i'll probably just splice
or well, the test ive done so far seem to confirm my thought of the last element in the array overriding
but i'm not too keen on actually doing it that way
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
yeah they're all for the members
i could do it that way indeed, thanks for the advice!
this is for a close ticket command, thus the permissions i edit are for the member that created the ticket, and its setting the SendMessages permission to false Now, if i spread the current permissions, and then add the updated ones, this means the array includes both the current permissions (in which the SendMessages permission is set to true), and the new one, in which it is set to false. Which one of these will override? I assume since the edited ones are the last to be pushed into the array, they will override but i'm unsureYou can use
PermissionOverwrites.resolveOverwriteOptions
method to correctly edit your existed overwrites
@luna🌈 (static) PermissionOverwrites.resolveOverwriteOptions()
Resolves bitfield permissions overwrites from an object.
I haven't studied the question enough, sorry...
no worries! i currently cant check anything, will do tomorrow!
So i've spread those into an arrayHere's an example how you can use this: Unfortunately, now Idk how to use it with your array without workarounds, but maybe you'll think of something better or will review my method to storage new permissions P.s. I doesn't test this, code may have issues, but I want to make up my thought to you
PermissionOverwriteOptions
An object mapping permission flags to
true
(enabled), null
(unset) or false
(disabled). ```js (more...)I think that's all my things for today
ive tried it but i could not get it to work, i found a solution myself though! thanks for the help!
Oh.. okay. Can you share your solution, please?
this is just the core test i did, the only thing i just need to add is to pass in the current allowed perms as
el.allow
but i have to remove the SendMessages from it firstLooks hard, but thanks. Maybe I use it in future 🙂
its funky but it works
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
oh thats indeed a good way to do it!