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.
No description
14 Replies
d.js toolkit
d.js toolkit12mo 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! - Marked as resolved by OP
remyShift
remyShiftOP12mo ago
discord js version is v14.14.1 and node version is v21.5.0
Svitkona
Svitkona12mo ago
you can pass permissions in the options object you pass to create https://old.discordjs.dev/#/docs/discord.js/14.14.1/typedef/RoleCreateOptions
remyShift
remyShiftOP12mo ago
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 ?
Svitkona
Svitkona12mo ago
you can remove specific permissions from a PermissionsBitField using https://old.discordjs.dev/#/docs/discord.js/14.14.1/class/PermissionsBitField?scrollTo=remove
remyShift
remyShiftOP12mo ago
something like that ?
No description
Svitkona
Svitkona12mo ago
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 in
remyShift
remyShiftOP12mo ago
if 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 permission
Svitkona
Svitkona12mo ago
yes
remyShift
remyShiftOP12mo ago
but if he put all perm on true he put some perm i doesnt want
Svitkona
Svitkona12mo ago
yeah true, you should remove the ones you don't want
remyShift
remyShiftOP12mo ago
like admin or other
Svitkona
Svitkona12mo ago
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
remyShift
remyShiftOP12mo ago
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
Want results from more Discord servers?
Add your server