Is there any utility to check if a member has permission to run a command?

FFiery1/15/2023
Hi! I have a bot that needs to check if a member has permission to run a command and then do something accordingly (eg remove a role) and I'd rather not write something to check if the member has permission to use a command if it already exists
SSpinel1/15/2023
:_: [Sapphire](https://www.sapphirejs.dev) docs results:
[Interfaces / Interface: CommandOptions / Properties​ / requiredUserPermissions​](https://www.sapphirejs.dev/docs/Documentation/api-framework/interfaces/CommandOptions#requireduserpermissions)
BBen8551/15/2023
You can pass in a Permissionresolvable to the requiredUserPermissions option on a command to make sure the user running it has that permission.
FFiery1/15/2023
Not like that permission
FFiery1/15/2023
I want to know if the user is allowed to run a command based on the slash command's permissions
FFiery1/15/2023
the guild may have overridden them
FFiery1/15/2023
it's a little confusing
BBen8551/15/2023
I'm not sure I follow then. If the guild overrode the perms and the user doesnt have the ability to run the slash command, your bot should never receive an interaction.
FFiery1/15/2023
The command in question gives the user a role, I need to know if the user loses access to the command to then remove the role accordingly
FFiery1/15/2023
I think I need https://discord.js.org/#/docs/discord.js/main/class/ApplicationCommandPermissionsManager?scrollTo=has but instead of it checking a single permission id, it'd iterate through and calculate whether the user has the ability to run a command
FFiery1/15/2023
I basically need to check if a member can run a command outside of the command itself, instead in a listener
BBen8551/15/2023
I'm not sure if there is an event sent to the client on that kind of update. Scanning through https://www.sapphirejs.dev/docs/Documentation/api-framework/#events doesn't show anything obvious but I might have missed something.
FFiery1/15/2023
I know there isn't a event unfortunately
FFiery1/15/2023
I'd probably use it in a member update as the user's ability to use a command would change based on roles
FFiery1/15/2023
I just need a function to check if a user can run a command based on the guild overrides
Solution
FFavna1/27/2023
You'll have to write your own function. Feel free to make a PR to @sapphire/discord.js-utilities after the fact.