Permissions
is there a way to know what permissions my bot has in a specific channel? (ignoring the role permissions he has when we got to the guild)
because when I use
interaction.channel.permissionsFor(interaction.guild.members.me)
returns the combined permissions he has in role perspective and channel8 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!if you're looking to just check permission overwrites, you'd want to parse
<GuildChannel>.permissionOverwrites.cache
if you're just looking for an overwrite explicitly for the client member, you can just use ...cache.get()
since the overwrite id is the member/role's idim looking to just simply check if he has the necessary permissions within the specific channel the interaction came from (in my case guild channel that is a voice channel type) or just check if the permissions for him is exists specificly.
cache will be updated live? should i fetch it?
on the assumption you have the
Guilds
intent, it would be up to date
that being said, I'm not really sure what you'd need to differentiate between overwrites and accumulated permissions foryea, so even if there is no role in the channel of my bot. it still returns the permissions he got in (everyone + bot role in guild). And I need to check for the channel permissions
is there a way to check if he has permission overwrite within a channel?
thanks. I will give it a try
yea so, I give him the following list of permissions in guild role:
but still I need to add for the channel his role with the following:
in order for him to function with my current behivor
yep, thats exactly right, im changing the everyone role
hmm, still it should make it returned but it didnt
Like he continue becuase he "has" the permissions, but infact the bot is throwing error missing permissions. when he does have the role in the channel its not throwing any error
:property: CommandInteraction#appPermissions
@14.16.2
Set of permissions the application or bot has within the channel the interaction was sent fromI hope I've explained it well, its kinda complicated messing with the permissions
true, thats exactly what I need but for a button interaction
oh nice, thank you very much
still didn't work, when everyone is on "null" and there is no permissions for the bot in the channel he doesnt have the neseccery perms.
code:
output:
he is tryin to edit a message but he has no permissions
Yes
The bot is adding to its self the permissions overwrites at a certain point. And if a user will remove it , it will cause issues to my bot. So I want to check at any time if he has it, if not just return a message
But it’s not checking it properly
I want to relate only to the channels and it doesn’t
Like to relate to my bot permissions in a specific channel where the interaction came from as I mentioned
Exactly right
That is way I need to check only the bot permission overwrite in the channel I guess
@Qjuh that was the solution, using permissionOverwrite, thank you very much for your help.
@duck btw I do need to fetch the channel in order for the cache to be updated, I got accross some issues if I dont fetch it which its not updated, so I do fetch everytime altough its slower
I am messing with sweepers maybe that’s why