Returning bot's missing permissions
Hey, i made a function, which is supposed to check for the missing permissionsn in the array of permissions i give it. Instead, it either returns all permissions, or no permissions at all.
Code for function: https://srcb.in/8ylqAtQbhb
How i utilize the function: https://srcb.in/Jlacln3RD9
Permissions for the channel i'm checking in (Thread channel): pic attached
How the bot responds: pic attached
![No description](https://cdn.answeroverflow.com/1198607963145896017/image.png)
![No description](https://cdn.answeroverflow.com/1198607963322077314/image.png)
6 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!1. I don't see the point of checking both global and channel specific permissions. A permission can be allowed globally, but denied in the channel. Your code does wrong thing.
2.
permissions.has((a || b) && c)
checks if (a or b) and c has in the permissions (means one of). You need to check (permissions.has(a) || permissions.has(b)) && permissions.has(c)
.
3. Your returnMissingPermissions
does a lot of unnecessary things. You can just filter permissions, map by keys adding the formatting and then join the array.alright i was testing a bit with this function.
this is my function now (for testing):
this is how i call my function:
where permissions is:
and perms is:
however, the log is an emtpy array
these are my perms btw
![No description](https://cdn.answeroverflow.com/1198640910469177365/image.png)
Isn't the function supposed to check which permissions from the array
perms
is missing from permissions the bot has (which is permissions
)?
WAIT oh
I thought I was passing the bot's permissions
let me edit the code
this is how i now call my function
still logging an empty array
alright so to test this, i denied the everyone
role the perms, and now it's logging the 3 perms missing.
So now i believe i'm supposed to check for both, instead of checking only for channel permission overwrites
alright tysm
okay tysm
Okay it's a bit late, but i've now edited the code, to check for permissionsOverwrites. When i allow the Create Posts
permissions on the channel, both CreatePrivateThreads
and CreatePublicThreads
return as missing and the permission SendMessages
(not SendMessagesInThreads
) passes (doesn't return as missing) even though when that permission in the channel was denied, it was returned missing
This is the function:
and this is how i call it:
what about Send messages in posts
permission?