How would I lock a command behind a specific role?

I want to make a command that only a specific role can run.
10 Replies
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna5mo ago
You can only limit it by permission
Stie (old account)
Stie (old account)OP5mo ago
How could I do that?
treble/luna
treble/luna5mo ago
Server admins can limit it to roles in the server settings
d.js docs
d.js docs5mo ago
:method: ContextMenuCommandBuilder#setDefaultMemberPermissions() @1.9.0 Sets the default permissions a member should have in order to run this command.
Stie (old account)
Stie (old account)OP5mo ago
I mean like, I want to set a command to not be available for anyone, just if you have a specific role. I saw other people doing it like that somehow. I am trying to figure out how.
treble/luna
treble/luna5mo ago
It is yes. But not via discord.js Server admins can adjust it in server settings
Stie (old account)
Stie (old account)OP5mo ago
I dont want the whole bot to be a specific role only.
treble/luna
treble/luna5mo ago
or alternatively with the oauth2 token of an admin, but thats not djs related
Server admins can adjust it in server settings
jacob
jacob5mo ago
server admins can adjust it in their server, meaning command permissions are controlled by the server admins, not the bot developer. you can however set a default permission (e.g. for mod commands so they're restricted before server admins set perms)

Did you find this page helpful?