-
Basically as the title states. Wondering if there's a way to essentially hide slash commands from users if they lack the required permissions to run them. I know you can do it within the Discord integration tab if you have admin / owner rights- but I'll explain more about why I'm asking this down a bit further. I know you can use decorators where the command functions are defined to prevent execution like so. # Only let the command run if the user has the `ban_members` permission
@commands.has_permissions(ban_members=True) But that doesn't do anything about their visibility. I recently invited another bot to my server (Kettu) and it does this automatically without any need for input on my end. So I was wondering if this behavior is possible to replicate in the latest version of discord.py. (I am aware that Kettu uses a custom fork of discord.js, and not all features may have parity between the two. But that's why I thought it'd be worth it to ask) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, @app_commands.default_permissions(ban_members=True) This decorator changes the default permission needed for seeing/using the command Discord side whereas has_permissions does a check on the bot side to be sure the user running the command has the permissions. |
Beta Was this translation helpful? Give feedback.
Hey,
I think you're looking for this https://discordpy.readthedocs.io/en/stable/interactions/api.html?highlight=default_permissions#discord.app_commands.default_permissions
@app_commands.default_permissions(ban_members=True)
This decorator changes the default permission needed for seeing/using the command Discord side whereas has_permissions does a check on the bot side to be sure the user running the command has the permissions.