When you create a Discord bot and generate an authorization URL, you must specify the permissions the bot requires. The permissions are represented as a single integer, not a list of checkboxes. This integer is the sum of specific permission values defined by Discord. If you set the wrong integer, your bot may lack access to channels, messages, or server management features. This article explains how to calculate the Discord permission integer manually and using tools.
Key Takeaways: How to Build the Correct Bot Permission Integer
- Discord Developer Portal > Bot > Permissions > Generate Integer: Built-in tool that adds permission values automatically.
- Bitwise OR operation in code: Use the bitwise OR operator (|) to combine permission flags in JavaScript, Python, or other languages.
- Manual addition of permission values: Sum the decimal values of each required permission from Discord’s official list.
What Is the Discord Permission Integer and How Is It Calculated
Discord uses a bitfield to represent bot permissions. Each permission is assigned a specific power-of-two value. For example, the permission to send messages has a value of 2048, while the permission to manage messages is 8192. When you add these values together, you get a single integer that encodes all granted permissions. Discord’s OAuth2 authorization URL includes the permissions parameter with this integer.
The underlying mechanism is a bitmask. Each bit in a 64-bit integer represents one permission. If the bit is set to 1, the permission is granted. If it is 0, the permission is denied. The integer you see in the URL is the decimal representation of that binary bitmask. Understanding this helps you verify that the integer matches the permissions you intended to grant.
Permission Values Table
Discord defines permission values for general, text, voice, and advanced permissions. Here are the most common ones:
- Create Instant Invite: 1
- Kick Members: 2
- Ban Members: 4
- Administrator: 8
- Manage Channels: 16
- Manage Server: 32
- Add Reactions: 64
- View Audit Log: 128
- Priority Speaker: 256
- Stream: 512
- Read Messages / View Channels: 1024
- Send Messages: 2048
- Send TTS Messages: 4096
- Manage Messages: 8192
- Embed Links: 16384
- Attach Files: 32768
- Read Message History: 65536
- Mention Everyone: 131072
- Use External Emojis: 262144
- View Server Insights: 524288
- Connect (Voice): 1048576
- Speak (Voice): 2097152
- Mute Members: 4194304
- Deafen Members: 8388608
- Move Members: 16777216
- Use VAD: 33554432
- Change Nickname: 67108864
- Manage Nicknames: 134217728
- Manage Roles: 268435456
- Manage Webhooks: 536870912
- Manage Emojis and Stickers: 1073741824
The Administrator permission (8) grants all permissions and overrides any other integer calculation. If you set the integer to 8, the bot has full access regardless of other bits set.
Steps to Calculate the Permission Integer Manually
You can calculate the permission integer by adding the values of each permission you want to grant. This method works for small permission sets. For large sets, use the Developer Portal tool or code.
- List all required permissions
Write down every permission your bot needs. For example: Send Messages (2048), Read Messages (1024), Manage Messages (8192), and Embed Links (16384). - Look up the decimal value for each permission
Use the table above or Discord’s official documentation. Write the value next to each permission. - Add all values together
Sum the numbers: 2048 + 1024 + 8192 + 16384 = 27648. This is your permission integer. - Test the integer in the authorization URL
Construct the URL:https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=27648&scope=bot. Replace YOUR_CLIENT_ID with your bot’s client ID.
Using the Discord Developer Portal Permission Calculator
The Discord Developer Portal includes a visual permission calculator. This tool eliminates manual addition and reduces errors.
- Open the Discord Developer Portal
Go to https://discord.com/developers/applications and select your application. - Navigate to the Bot section
Click Bot in the left sidebar. - Scroll to the Permission section
Below the bot token area, find the Permissions section. It shows a list of checkboxes. - Check the required permissions
Click the checkboxes for each permission you need. The integer value updates automatically in the Generated Integer field below the list. - Copy the generated integer
Click the Copy button next to the integer. Use this value in your authorization URL.
Calculating the Permission Integer with Code
If you manage permissions programmatically, use a bitwise OR operation. This method is accurate and scalable.
JavaScript Example
const Permissions = {
SEND_MESSAGES: 2048,
READ_MESSAGES: 1024,
MANAGE_MESSAGES: 8192,
EMBED_LINKS: 16384
};
const permissionInteger = Permissions.SEND_MESSAGES | Permissions.READ_MESSAGES | Permissions.MANAGE_MESSAGES | Permissions.EMBED_LINKS;
console.log(permissionInteger); // Output: 27648
Python Example
from enum import IntFlag
class Permissions(IntFlag):
SEND_MESSAGES = 2048
READ_MESSAGES = 1024
MANAGE_MESSAGES = 8192
EMBED_LINKS = 16384
permission_integer = Permissions.SEND_MESSAGES | Permissions.READ_MESSAGES | Permissions.MANAGE_MESSAGES | Permissions.EMBED_LINKS
print(permission_integer) # Output: 27648
Common Mistakes When Setting the Permission Integer
Accidentally Including the Administrator Permission
Setting the Administrator permission (8) grants all permissions. This is often unintended and can be a security risk. Always verify that the integer does not include 8 unless you explicitly want full access.
Using the Wrong Permission Value for View Channels
The permission to view channels is 1024. Some users mistakenly use 1024 for sending messages. Sending messages is 2048. Mixing these values causes the bot to be unable to read or send messages in channels.
Forgetting to Include Essential Permissions
A bot that needs to read message history must include 65536. Without it, the bot cannot see past messages. Similarly, a music bot must include Connect (1048576) and Speak (2097152) to join voice channels.
Using the Integer from the OAuth2 URL Generator Instead of the Bot Section
The Developer Portal has two permission calculators: one in the Bot section and one in the OAuth2 URL Generator. Both produce the same integer. However, the OAuth2 URL Generator also includes scopes and redirect URIs. If you only need the integer, use the Bot section for simplicity.
Permission Integer Calculator: Manual vs Developer Portal vs Code
| Item | Manual Addition | Developer Portal | Code (Bitwise OR) |
|---|---|---|---|
| Accuracy | Prone to human error | High | High |
| Time required | Slow for many permissions | Fast | Fast |
| Requires internet | No | Yes | No |
| Best for | Small permission sets | Visual users | Automation and scripts |
The Discord permission integer is a bitmask that combines individual permission values. You can calculate it by adding decimal values, using the Developer Portal tool, or performing a bitwise OR in code. Manual addition works for a few permissions but risks errors. The Developer Portal is the easiest method for most users. Code-based calculation is best for developers who generate URLs dynamically. Always double-check that the integer matches the permissions your bot needs to function.