requiredClientPermissions check always rejecting
While
requiredUserPermissions: ['ManageRoles']
works great. The client check requiredClientPermissions: ['ManageRoles']
seems to always block.
It is throwing not a specific missing permissions error but an I was unable to resolve my permissions in the ${commandType} command invocation channel.
Unless I am doing something wrong, it looks like the problem is that the check is referencing the application id channel.permissionsFor(interaction.applicationId)
when it should be referencing either the clients guild member or user ID.
https://github.com/sapphiredev/framework/blob/179b21e7f74c4d9a506e1be98d7487f939ec0ae7/src/preconditions/ClientPermissions.ts#L71
When testing channel.permissionsFor(interaction.applicationId)
always resolved null, where as channel.permissionsFor(interaction.client.user.id)
and `channel.permissionsFor(interaction.guild.members.me)
always gave a valid bitfield
GitHub
framework/ClientPermissions.ts at 179b21e7f74c4d9a506e1be98d7487f93...
Discord bot framework built on top of discord.js for advanced and amazing bots. - framework/ClientPermissions.ts at 179b21e7f74c4d9a506e1be98d7487f939ec0ae7 · sapphiredev/framework
24 Replies
I use this on my bot and it works every time. I apply it via the decorator but I don’t think that matters. Did you ensure that permission was clicked when generating the invite? Mine used an admin link.
The bot has been in my server for years, no clue how I invited it. For sanity sake I kicked it and re-invited it with a fresh invite link with all permissions selected
&permissions=1099511627775&scope=bot
- Additionaly upon joining I gave it an existing role that has admin perms in addition to the managed role it already had.
Same output: 'I was unable to resolve my permissions in the chat input command invocation channel.'
Weird. I looked at my intents and nothing there to do with roles. Maybe someone smarter than I am can help
@Vladdy there shouldn't be a difference between the IDs?
Old applications have different ids
Between app and user
But I'm talking old old
@Deadlystrike can you log your clients user id and the interactions applicationId please
I do believe that I saw my client users id and the app id was different but let me recheck
You can see that in the dev portal too tbf
they are diff
..how old is your app
Snow-Stamp
Discord Snowflake to Timestamp Converter
Get the exact time and date from a Discord Snowflake
Dev Bot: 8/1/2016
Production Bot: 7/15/2016
.........first off thanks for using sapphire
Secondly yeah that makes sense for it to break then
@Favna we need a client user id fallback
For all permission checks
fallback or just always use it
Fallback
Any app past..2017 iirc has them tied
I mean i suppose we can always use it
otherwise I'm doing this
...
Are you high
no just tired from getting WoL not working
permissions = channel.permissionsFor(interaction.applicationId) ?? channel.permissionsFor(interaction.client.user?.id)
send my body a magic packet please
created a PR for this @Deadlystrike https://github.com/sapphiredev/framework/pull/616
GitHub
fix(ClientPermissions): fixed permission checking for old applicati...
Warning
This Pull Request needs sapphiredev/utilities#559 to be approved and merged beforehand. Once the linked Pull Request is merged, this one will receive its last commit.
🫡 building the branch now to test
If it gives type errors that's because of the linked PR and you can just ts-ignore any problematic lines for now
Strangely it didn't give any in CI...
Looking good so far, re-enabled the
requiredClientPermissions
checks and the command went through just fine, kicked the bot and re-invited with removed permissions and it threw a I am missing the following permissions to run this command: Manage Roles
as i would expect.Solution
Closing this as the fix has been released in v4.2.1