Discord¶
This guide walks you through creating a Discord bot and connecting it to prbot.
Step 1: Create a Discord application¶
- Go to the Discord Developer Portal
- Click New Application and give it a name (e.g.
prbot) - Go to the Bot section in the sidebar
Step 2: Configure the bot¶
-
Under Privileged Gateway Intents, enable:
- Message Content Intent — required for prbot to read message text and detect PR URLs
-
Optionally customise the bot's username and avatar
Message Content Intent
Without this intent enabled, the bot will not be able to read message contents and PR detection will not work. This is a privileged intent that must be explicitly enabled.
Step 3: Get the bot token¶
- In the Bot section, click Reset Token
- Copy the token — you will only see it once
Step 4: Invite the bot to your server¶
- Go to OAuth2 > URL Generator
- Select the following scopes:
botapplications.commands— required for the/prbotslash commands
- Select the following bot permissions:
- Read Messages/View Channels
- Read Message History
- Add Reactions
- Copy the generated URL and open it in your browser
- Select the server you want to add the bot to and click Authorize
Step 5: Configure prbot¶
Add the bot token to your .env file:
Nested delimiter
The double underscore (__) in PR_BOT_DISCORD__BOT_TOKEN is the nested config delimiter — it maps to settings.discord.bot_token internally.
Required permissions¶
| Permission | Purpose |
|---|---|
| Read Messages | See messages in channels |
| Read Message History | Backfill messages posted while offline |
| Add Reactions | React to messages with status emoji |
Required intents¶
| Intent | Purpose |
|---|---|
| Message Content | Read message text to detect PR URLs |
| Guilds | List guilds and channels the bot is in |
How it connects¶
Unlike Slack (which uses HTTP webhooks), the Discord integration connects via the Discord Gateway (WebSocket). When prbot starts:
- The bot connects to Discord's WebSocket gateway
- It receives
on_messageevents for all channels it can see - PR URLs are detected and processed in real time
- The cursor system tracks the last-seen message per channel for backfill on restart
No public URL or webhook endpoint is needed for Discord — only the bot token.
Slash commands¶
prbot registers /prbot as a native slash command group with subcommands like /prbot exclusions add and /prbot self-reviews mute. Discord's client renders these with typed parameters and auto-complete. See Commands for the full reference.
Commands are synced to each guild on bot startup — propagation is instant. If the bot isn't showing commands in your server, verify the bot was invited with the applications.commands OAuth scope.