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
- 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!You can only limit it by permission
How could I do that?
Server admins can limit it to roles in the server settings
:method: ContextMenuCommandBuilder#setDefaultMemberPermissions()
@1.9.0
Sets the default permissions a member should have in order to run this command.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.
It is yes. But not via discord.js
Server admins can adjust it in server settings
I dont want the whole bot to be a specific role only.
or alternatively with the oauth2 token of an admin, but thats not djs related
Server admins can adjust it in server settings
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)