Create new role with defined Perm
After several search and nothing found i would like to know if there is a way to create a role with specific permission ? See example in picutres, i check doc, internet etc and only see old anszer without bitfields.
14 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!
- ✅
Marked as resolved by OPdiscord js version is v14.14.1
and node version is v21.5.0
you can pass permissions in the options object you pass to create https://old.discordjs.dev/#/docs/discord.js/14.14.1/typedef/RoleCreateOptions
yeah i find that but i dont want to give a permission but to deny one
in my case deny the permission to send message
does it mean i must put all perm he should access exept the one to send message
?
you can remove specific permissions from a PermissionsBitField
using https://old.discordjs.dev/#/docs/discord.js/14.14.1/class/PermissionsBitField?scrollTo=remove
something like that ?
no, that won't work
try
permissions: new PermissionsBitField(PermissionsBitField.All).remove(PermissionsBitField.Flags.SendMessages)
if that works. not sure if there's a better way to do this, someone else might chime inif i understand what it does
it create a new ""set"" of permission for that role
it put all on true with
PermissionsBitField.All
then he remove the send message permissionyes
but if he put all perm on true
he put some perm i doesnt want
yeah true, you should remove the ones you don't want
like admin or other
you can find a list here https://discord-api-types.dev/api/discord-api-types-payloads/common#Variables
ah, you can use PermissionBitFields.Default
instead of PermissionBitFields.All
default would be ?
oh
it check the perm actual of the user
and copy it
thx i think is that method i must use
doesnt work
still got the perm to send messages
i'll check that thx for your advice
nvm it work