Dynamic disable Slash Command based on role

Is that possible dynamic enable a slash command for a specify role in a specifically guild?
7 Replies
Favna
Favna2y ago
If you're talking about fully disable i.e. it not showing in the UI, no, the Discord API has no option for that. You can set permissions that are required, that it. And even then server owners can overwrite whatever you set. You can use Sapphire preconditions however which are runtime checks.
Daniel Passos
Daniel Passos2y ago
Gotcha. I was think in something like what mee6 do like disable a whole module (a group of slash commands) in the backend or dynamic set it to be available only for a specific role. So if you are not qualified by the guild + module enable on backend + role the slash command does not even shows for you
Favna
Favna2y ago
Sapphire Framework
Implementing a discord.py like Cog system | Sapphire
Developer who come from the Python ecosystem may be familiar with the "[Cog]" system that discord.py has implemented.
Favna
Favna2y ago
but you will also need your own preconditions setting enabled to false will disable it for all users everywhere it's quite a bit of work but possible
Daniel Passos
Daniel Passos2y ago
I will search about it. Thanks!
KB
KB2y ago
I've actually made a plugin that is very similar to that for my own bot if you need ideas. Been running it in production with no issues so far. https://github.com/KBot-discord/plugins/tree/main/packages/modules
GitHub
plugins/packages/modules at main · KBot-discord/plugins
Sapphire plugins for KBot. Contribute to KBot-discord/plugins development by creating an account on GitHub.
KB
KB2y ago
Only issue is that it does not work with ESM due to how imports are loaded. Looking into that atm.
Want results from more Discord servers?
Add your server