Hide Slash/Context menu commands

I have a number of Slash and Context Menu commands that I would like to hide, unless the user holds certain permissions. These permissions, I want to define by role (e.g, the 'Moderator' role). The commands should only be visible for users who have that specific role. I know that the commands can be maintained on a per guild status, in my instance, the bot only exists and only ever will exist in the context of a single guild - and the list of role IDs that need access are limited. I know that changing the commands through the Integration tab in Discord - it is possible to effectively hide the commands from those who should not have access. How can I do this at a code level, and by using a role?
Solution:
You cannot. Through code you can only set it based on a permission level, not a role level. Discord API rules. The solution here is to set it to administrator in code then change it manually in the UI...
Jump to solution
5 Replies
Solution
Favna
Favna•4mo ago
You cannot. Through code you can only set it based on a permission level, not a role level. Discord API rules. The solution here is to set it to administrator in code then change it manually in the UI
Bejasc
Bejasc•4mo ago
It's workable, but I wonder if the re-registration of the command when it's re-deployed will knock it back out.
Favna
Favna•4mo ago
It won't
Favna
Favna•4mo ago
Also as a rule of thumb: https://tryitands.ee
Bejasc
Bejasc•4mo ago
thanks 😉
Want results from more Discord servers?
Add your server