channelUpdate compare permissions
Hey there, I tried using the channelUpdate event to get the difference between the old permissions and the new channel permissions.
There is a slight issue though. Upon using this line to check if the permissions are changed, it always logs false in console, making the permissions check basically usesless.
7 Replies
- 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! Collection#difference()
The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
So by changing the if condition to
should log true instead? because once I tried it and changed the slowmode of the channel, it logged true in console
an empty collection is truthy
it would not find the case where a permission is changed instead though
it's not empty though
regardless, that if statement will always return true
old permissions
[{"id":"835417069490274344","type":0,"allow":"34628193280","deny":"344134254608"},{"id":"753224027899822160","type":0,"allow":"536871936","deny":"0"}]
new permissions
[{"id":"753224027899822160","type":0,"allow":"1024","deny":"536870912"},{"id":"835417069490274344","type":0,"allow":"34628193280","deny":"344134254608"}]
(using JSON.stringify())
ah in order to detect the change correct?
welp, i get the same collection regardless of permission/slowmode changes
The issue which prevents the old permissions to be the same as the new permissions upon slowmode change is just the fact that the permissions are given in different positions within the array
I removed .difference
it did not affect the result
the changed permissions is just me testing if the check actually works