Discord uses a bitfield, a single large number, to store all of a role or user’s permissions in a server. If you are a bot developer or a server admin working with the Discord API, you need to know how to compute this bitfield value manually or using a calculator. The bitfield is a 53-bit integer where each bit represents a specific permission. This article explains how the bitfield works, how to calculate it by hand, and how to use the official Discord permission calculator to verify your values.
Key Takeaways: How to Compute a Discord Permission Bitfield
- Shift and OR method: Shift each permission value by its bit position and combine them using bitwise OR
- Discord Developer Portal > Bot > Permission Calculator: Visual tool to select permissions and get the final bitfield integer
- API field “permissions”: The bitfield is passed as a string to avoid JavaScript integer precision issues
How the Discord Permission Bitfield Works
Every permission in Discord has a fixed bit position starting from 0. For example, the CREATE_INSTANT_INVITE permission is bit 0, KICK_MEMBERS is bit 1, and so on. The bitfield is a 53-bit integer because Discord uses JavaScript and the maximum safe integer in JavaScript is 2^53 – 1. When you combine multiple permissions, you set the bits at each permission’s position to 1. All other bits remain 0. The final number is the sum of all 2^position values for each enabled permission.
Permission Bit Positions
Discord defines permissions in a specific order. The first few positions are:
- Bit 0: CREATE_INSTANT_INVITE (value 1)
- Bit 1: KICK_MEMBERS (value 2)
- Bit 2: BAN_MEMBERS (value 4)
- Bit 3: ADMINISTRATOR (value 8)
- Bit 4: MANAGE_CHANNELS (value 16)
- Bit 5: MANAGE_GUILD (value 32)
- Bit 6: ADD_REACTIONS (value 64)
- Bit 7: VIEW_AUDIT_LOG (value 128)
- Bit 8: PRIORITY_SPEAKER (value 256)
- Bit 9: STREAM (value 512)
- Bit 10: VIEW_CHANNEL (value 1024)
- Bit 11: SEND_MESSAGES (value 2048)
- Bit 12: SEND_TTS_MESSAGES (value 4096)
- Bit 13: MANAGE_MESSAGES (value 8192)
- Bit 14: EMBED_LINKS (value 16384)
- Bit 15: ATTACH_FILES (value 32768)
- Bit 16: READ_MESSAGE_HISTORY (value 65536)
- Bit 17: MENTION_EVERYONE (value 131072)
- Bit 18: USE_EXTERNAL_EMOJIS (value 262144)
- Bit 19: VIEW_GUILD_INSIGHTS (value 524288)
- Bit 20: CONNECT (value 1048576)
- Bit 21: SPEAK (value 2097152)
- Bit 22: MUTE_MEMBERS (value 4194304)
- Bit 23: DEAFEN_MEMBERS (value 8388608)
- Bit 24: MOVE_MEMBERS (value 16777216)
- Bit 25: USE_VAD (value 33554432)
- Bit 26: CHANGE_NICKNAME (value 67108864)
- Bit 27: MANAGE_NICKNAMES (value 134217728)
- Bit 28: MANAGE_ROLES (value 268435456)
- Bit 29: MANAGE_WEBHOOKS (value 536870912)
- Bit 30: MANAGE_EMOJIS_AND_STICKERS (value 1073741824)
- Bit 31: USE_APPLICATION_COMMANDS (value 2147483648)
- Bit 32: REQUEST_TO_SPEAK (value 4294967296)
- Bit 33: MANAGE_EVENTS (value 8589934592)
- Bit 34: MANAGE_THREADS (value 17179869184)
- Bit 35: CREATE_PUBLIC_THREADS (value 34359738368)
- Bit 36: CREATE_PRIVATE_THREADS (value 68719476736)
- Bit 37: USE_EXTERNAL_STICKERS (value 137438953472)
- Bit 38: SEND_MESSAGES_IN_THREADS (value 274877906944)
- Bit 39: USE_EMBEDDED_ACTIVITIES (value 549755813888)
- Bit 40: MODERATE_MEMBERS (value 1099511627776)
Steps to Compute the Bitfield Value
You can compute the bitfield manually using the shift-and-add method or use Discord’s built-in permission calculator. Both methods produce the same result.
Method 1: Manual Calculation Using Bitwise OR
- List the permissions you want to enable
Write down each permission name exactly as it appears in the Discord API documentation. For example: KICK_MEMBERS, BAN_MEMBERS, MANAGE_CHANNELS. - Find the bit position for each permission
Use the list above to find the bit position. KICK_MEMBERS is bit 1, BAN_MEMBERS is bit 2, MANAGE_CHANNELS is bit 4. - Calculate 2 raised to the bit position for each permission
For bit 1: 2^1 = 2. For bit 2: 2^2 = 4. For bit 4: 2^4 = 16. - Add all values together using bitwise OR
In programming:bitfield = (1 << 1) | (1 << 2) | (1 << 4)which equals 2 + 4 + 16 = 22. The bitfield value is 22. - Convert to a string for the API
Discord expects the permissions field as a string to avoid precision loss. Send "22" in your API call.
Method 2: Using the Discord Permission Calculator
- Go to the Discord Developer Portal
Open discord.com/developers/applications and sign in. - Select your bot application
Click on the application you want to configure. If you don't have one, create a new application. - Open the Bot section
In the left sidebar, click Bot. - Scroll to the Permission Calculator
Below the bot token section, you will see a list of checkboxes labeled with each permission. - Check the permissions you need
Click the checkbox next to each permission. As you select, the calculator shows the bitfield integer value in the box labeled Permissions Integer. - Copy the integer value
Click the Copy button next to the integer value. Paste it into your bot's invite URL or API call.
Common Mistakes When Computing a Permission Bitfield
Using the Wrong Bit Position
Discord occasionally adds new permissions and shifts bit positions. Always refer to the latest Discord API documentation for the current bit position list. Using an outdated list gives you an incorrect bitfield.
JavaScript Integer Precision Limit
JavaScript can safely represent integers up to 2^53 - 1, which is about 9 quadrillion. Discord's bitfield uses up to bit 40, which is 2^40 = 1,099,511,627,776. This is well within the safe range. However, if you combine all permissions, the sum can exceed the safe integer limit. Always pass the bitfield as a string in API requests to avoid rounding errors.
Forgetting the ADMINISTRATOR Permission Override
When you set the ADMINISTRATOR permission (bit 3), it grants all other permissions automatically. You do not need to add other permissions to the bitfield. If you include both ADMINISTRATOR and other permissions, the bitfield still works, but it wastes space. Discord ignores extra bits when ADMINISTRATOR is set.
Permission Bitfield Calculation: Manual vs Calculator
| Item | Manual Calculation | Discord Permission Calculator |
|---|---|---|
| Method | Bitwise OR of 2^position values | Checkbox selection with automatic sum |
| Accuracy | Depends on correct bit positions | Always uses current Discord API positions |
| Time required | 5-10 minutes for complex sets | 30 seconds |
| Error prone | High for many permissions | Low |
| Best for | Learning how bitfields work | Production bot development |
You now know how to compute a Discord permission bitfield manually and using the official calculator. If you are building a bot, always use the calculator to avoid mistakes. For a deeper understanding, practice calculating bitfields for a few test permission sets and verify the results with the calculator. The bitfield system is efficient but requires precise bit positions, so double-check your values before deploying your bot.