Discord Setup Guide
February 2, 2026 ยท View on GitHub
Create a Discord Bot
- Go to Discord Developer Portal
- Click New Application and give it a name
- Go to Bot in the left sidebar
- Click Reset Token and copy the token (starts with
MTI...) - Save it as
DISCORD_BOT_TOKENin your.envfile
Enable Required Intents
In the Bot settings, enable these Privileged Gateway Intents:
- Message Content Intent (required to read message content)
Set Bot Permissions
Go to OAuth2 > URL Generator:
-
Select scopes:
bot -
Select permissions:
- Read Messages/View Channels
- Send Messages
- Read Message History
- Attach Files (for image responses)
-
Copy the generated URL and open it to invite the bot to your server
Configuration
Add to your .env file:
DISCORD_BOT_TOKEN=your_bot_token_here
DISCORD_TRIGGER=!oc # Optional, default: !oc
Run
bun connectors/discord.ts
Usage
In any channel where the bot has access, use @mentions or the trigger prefix:
@your-bot-name what time is it?
@your-bot-name who are you?
!oc what time is it?
!oc search for opencode documentation
!oc /help
!oc /clear
You can also DM the bot directly.
Troubleshooting
Bot doesn't respond
- Check that Message Content Intent is enabled
- Verify the bot has permissions in the channel
- Check logs for errors
"Missing Access" error
- Re-invite the bot with correct permissions
- Check channel-specific permission overwrites