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 toolkit3mo 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/luna3mo ago
You can only limit it by permission
Stiefanek
StiefanekOP3mo ago
How could I do that?
treble/luna
treble/luna3mo ago
Server admins can limit it to roles in the server settings
d.js docs
d.js docs3mo ago
:method: ContextMenuCommandBuilder#setDefaultMemberPermissions() @1.9.0 Sets the default permissions a member should have in order to run this command.
Stiefanek
StiefanekOP3mo 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/luna3mo ago
It is yes. But not via discord.js Server admins can adjust it in server settings
Stiefanek
StiefanekOP3mo ago
I dont want the whole bot to be a specific role only.
treble/luna
treble/luna3mo ago
or alternatively with the oauth2 token of an admin, but thats not djs related
Server admins can adjust it in server settings
ethan<333
ethan<3333mo 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)
Want results from more Discord servers?
Add your server