Zrzur Developers

Roles and permissions

How permissions are calculated

  1. The server owner can do everything.
  2. Otherwise start from the server's default permissions (@everyone).
  3. Add the permissions of every role the member has (allow), then remove what roles deny, from the lowest to the highest ranked role.
  4. In a channel, apply the channel's default override, then the role overrides, the same way.
  5. A member in timeout keeps only View Channel and Read Message History.

Permissions are a 64-bit number; each permission is one bit. Use BigInt in JavaScript: a plain number cannot hold every bit exactly.

const SEND_MESSAGE = 1n << 22n;
const canSend =
  (BigInt(interaction.user_permissions_string) & SEND_MESSAGE) === SEND_MESSAGE;

Every interaction tells you the permissions of the person who used it (user_permissions_string) and of your bot (app_permissions_string) in that channel, so you rarely need to compute them yourself.

Permission strings

Endpoints in this reference name permissions such as Timeout Members. In an error the same permission is written TimeoutMembers, the first column of the table below. Add values to send several: Kick Members (64) and Ban Members (128) are 192.

Threads and forums

CreateThreads, SendMessageInThreads and CreateForumPosts are on for @everyone by default. Deny them on a role, or on a channel, and those people can only read. They are read on the parent channel, on top of Send Messages.

Ranking

Roles have a rank; a lower number ranks higher. A bot can only edit, give, take, kick, ban or time out members and roles that rank below its own highest role. Otherwise the server answers NotElevated. Ask server admins to move your bot's role up if your bot moderates.

Permission bits

PermissionBitValue
ManageChannel01Manage the channel or channels on the server
ManageServer12Manage the server
ManagePermissions24Manage permissions on servers or channels
ManageRole38Manage roles on server
ManageCustomisation416Manage server customisation (includes emoji)
KickMembers664Kick other members below their ranking
BanMembers7128Ban other members below their ranking
TimeoutMembers8256Timeout other members below their ranking
AssignRoles9512Assign roles to members below their ranking
ChangeNickname101024Change own nickname
ManageNicknames112048Change or remove other's nicknames below their ranking
ChangeAvatar124096Change own avatar
RemoveAvatars138192Remove other's avatars below their ranking
ViewChannel201048576View a channel
ReadMessageHistory212097152Read a channel's past message history
SendMessage224194304Send a message in a channel
ManageMessages238388608Delete messages in a channel
ManageWebhooks2416777216Manage webhook entries on a channel
InviteOthers2533554432Create invites to this channel
SendEmbeds2667108864Send embedded content in this channel
UploadFiles27134217728Send attachments and media in this channel
Masquerade28268435456Masquerade messages using custom nickname and avatar
React29536870912React to messages with emojis
Connect301073741824Connect to a voice channel
Speak312147483648Speak in a voice call
Video324294967296Share video in a voice call
MuteMembers338589934592Mute other members with lower ranking in a voice call
DeafenMembers3417179869184Deafen other members with lower ranking in a voice call
MoveMembers3534359738368Move members between voice channels
Listen3668719476736Listen to other users
MentionEveryone37137438953472Mention everyone and online members
MentionRoles38274877906944Mention roles
BypassSlowmode39549755813888Bypass slowmode
ViewAuditLogs401099511627776Access server audit logs
UseExternalEmojis412199023255552Allow external emoji usage
ManageJoinRequests424398046511104(never in the default permissions; the owner grants it to roles)
CreateThreads438796093022208Start a thread in a text channel
SendMessageInThreads4417592186044416Write in threads and in forum posts (a forum post is a thread)
CreateForumPosts4535184372088832Start a post in a forum
Administrator4670368744177664Every right in every channel of the server, whatever its overrides say
UseSoundboard47140737488355328Play the server's soundboard sounds in a voice call
ManageSoundboard48281474976710656Add, change and remove the server's soundboard sounds

Reference

PUT /channels/{target}/permissions/{role_id}

Set Role Permission. Sets permissions for the specified role in this channel. Channel must be a TextChannel.

Permissions: Channel:ManagePermissions · Rate limit: channels, 15 / 10 s

PUT /channels/{target}/permissions/default

Set Default Permission. Sets permissions for the default role in this channel. Channel must be a Group or TextChannel. A channel synced with its category stops following it: it keeps a copy of the category's permissions and the change applies on top.

Permissions: Channel:ManagePermissions · Rate limit: channels, 15 / 10 s

PUT /channels/{target}/permissions/members/{user_id}

Set Member Permission. Sets one member's permissions in this channel, applied after every role (for example a ticket only its author and the staff can see). An empty override (allow 0, deny 0) removes it. Channel must be a TextChannel. Needs Manage Permissions in the channel, a higher rank than the member, and only the permissions you hold yourself.

Permissions: Channel:ManagePermissions · Rate limit: channels, 15 / 10 s

POST /channels/{target}/permissions/sync

Sync Permissions With Category. The channel follows its category's permissions again; its own default and role overrides are cleared. Per-member overrides stay.

Permissions: Channel:ManagePermissions · Rate limit: channels, 15 / 10 s

PUT /servers/{target}/categories/{category_id}/permissions/{role_id}

Set Category Role Permission. Sets a role's permissions for a category. Channels synced with the category use them instead of their own. An empty override removes it.

Rate limit: servers, 5 / 10 s

PUT /servers/{target}/categories/{category_id}/permissions/default

Set Category Default Permission. Sets the default permissions for a category. Channels synced with the category use them instead of their own.

Rate limit: servers, 5 / 10 s

PUT /servers/{target}/permissions/{role_id}

Set Role Permission. Sets permissions for the specified role in the server.

Permissions: Channel:ManagePermissions · Rate limit: servers, 5 / 10 s

PUT /servers/{target}/permissions/default

Set Default Permission. Sets permissions for the default role in this server.

Permissions: Channel:ManagePermissions · Rate limit: servers, 5 / 10 s

POST /servers/{target}/roles

Create Role. Creates a new server role.

Permissions: Channel:ManageRole · Rate limit: servers, 5 / 10 s

DELETE /servers/{target}/roles/{role_id}

Delete Role. Delete a server role by its id.

Permissions: Channel:ManageRole · Rate limit: servers, 5 / 10 s

GET /servers/{target}/roles/{role_id}

Fetch Role. Fetch a role by its id.

Rate limit: servers, 5 / 10 s

PATCH /servers/{target}/roles/{role_id}

Edit Role. Edit a role by its id.

Permissions: Channel:ManageRole · Rate limit: servers, 5 / 10 s

PATCH /servers/{target}/roles/ranks

Edits server roles ranks. Edit's server role's ranks.

Permissions: Channel:ManageRole · Rate limit: servers, 5 / 10 s