Discord Integration Configuration¶
See also: Discord Verification Frontend Implementation for the frontend verification flow.
Overview¶
The LBS Foundry platform integrates with Discord to provide community engagement and user verification features. This document outlines the configuration requirements and setup process for the Discord integration.
Required Configuration Keys¶
The Discord integration requires the following configuration keys to be set in your appsettings.json or environment variables:
Core Discord Settings¶
| Configuration Key | Description | Example Value | Required |
|---|---|---|---|
Discord:BotToken |
Discord bot authentication token | YOUR_DISCORD_BOT_TOKEN |
Yes |
Discord:ApplicationId |
Discord application ID | YOUR_DISCORD_APPLICATION_ID |
Yes |
Discord:PublicKey |
Discord application public key | YOUR_DISCORD_PUBLIC_KEY |
Yes |
Discord:VerifiedRoleName |
Name of the role to assign verified users | Verified |
Yes |
Discord:VerificationChannelName |
Name of the channel for verification instructions | verification |
Yes |
Discord:LogLevel |
Logging level for Discord operations | Information |
No (defaults to Information) |
Verification Settings¶
| Configuration Key | Description | Example Value | Required |
|---|---|---|---|
Discord:Verification:HmacSecret |
Secret key for HMAC token generation | YOUR_HMAC_SECRET_KEY |
Yes |
Discord:Verification:BaseUrl |
Base URL for verification links | https://ballr.lbs.com |
Yes |
Discord:Verification:TokenExpiryMinutes |
Token expiration time in minutes | 60 |
No (defaults to 60) |
Configuration Example¶
appsettings.json¶
{
"Discord": {
"BotToken": "YOUR_DISCORD_BOT_TOKEN",
"ApplicationId": "YOUR_DISCORD_APPLICATION_ID",
"PublicKey": "YOUR_DISCORD_PUBLIC_KEY",
"VerifiedRoleName": "Verified",
"VerificationChannelName": "verification",
"LogLevel": "Information",
"Verification": {
"HmacSecret": "YOUR_HMAC_SECRET_KEY_FOR_DISCORD_VERIFICATION",
"BaseUrl": "https://ballr.lbs.com",
"TokenExpiryMinutes": 60
}
}
}
Environment Variables¶
For production environments, use environment variables instead of storing sensitive values in configuration files:
# Core Discord Settings
Discord__BotToken=YOUR_DISCORD_BOT_TOKEN
Discord__ApplicationId=YOUR_DISCORD_APPLICATION_ID
Discord__PublicKey=YOUR_DISCORD_PUBLIC_KEY
Discord__VerifiedRoleName=Verified
Discord__VerificationChannelName=verification
# Verification Settings
Discord__Verification__HmacSecret=YOUR_HMAC_SECRET_KEY
Discord__Verification__BaseUrl=https://ballr.lbs.com
Discord__Verification__TokenExpiryMinutes=60
Discord Server Setup¶
Required Discord Server Configuration¶
- Create Verification Role
- Create a role with the name specified in
Discord:VerifiedRoleName(default: "Verified") - Configure role permissions as needed for verified users
-
Ensure the bot's role is higher in the hierarchy than the verified role
-
Create Verification Channel
- Create a text channel with the name specified in
Discord:VerificationChannelName(default: "verification") - Set channel permissions so all users can view but only the bot can send messages
-
The bot will automatically post verification instructions in this channel
-
Bot Permissions The Discord bot requires the following permissions:
- Manage Roles: To assign/remove the verified role
- Read Messages/View Channels: To read commands
- Send Messages: To respond to users
- Use Slash Commands: To register and handle slash commands
- Manage Messages: To manage verification channel messages
Discord Bot Setup¶
- Create Discord Application
- Go to https://discord.com/developers/applications
- Click "New Application" and give it a name
- Navigate to the "Bot" section
- Click "Add Bot"
-
Copy the bot token for
Discord:BotToken -
Configure Bot Settings
- Enable "Server Members Intent" for role management
-
Disable "Public Bot" if you only want to invite it to specific servers
-
Get Application Credentials
-
In "General Information", copy:
- Application ID for
Discord:ApplicationId - Public Key for
Discord:PublicKey
- Application ID for
-
Invite Bot to Server
- In "OAuth2 > URL Generator"
- Select scopes:
bot,applications.commands - Select permissions mentioned above
- Use the generated URL to invite the bot to your server
Verification Flow¶
- User Initiates Verification
- User types
/verifyin any Discord channel - Bot generates a unique verification token
-
Bot sends a private message with verification link
-
Web Verification
- User clicks the verification link
- Link redirects to the ballr website
-
User completes authentication on the website
-
Verification Completion
- Website calls the verification endpoint with the token
- System links Discord account to ballr account
- Bot assigns the verified role to the user
- User gains access to verified-only channels
Troubleshooting¶
Common Issues¶
- Bot Not Responding to Commands
- Ensure bot token is correct
- Check bot is online in Discord
-
Verify bot has permission to read messages in the channel
-
Role Not Being Assigned
- Verify role name matches configuration
- Ensure bot role is higher than verified role in hierarchy
-
Check bot has "Manage Roles" permission
-
Verification Link Not Working
- Confirm
BaseUrlis correct and accessible - Check HMAC secret matches between Discord bot and web API
- Verify token hasn't expired (default 60 minutes)
Logging¶
Enable debug logging for detailed troubleshooting:
{
"Discord": {
"LogLevel": "Debug"
},
"Logging": {
"LogLevel": {
"LBS.Core.Integration.Discord": "Debug"
}
}
}
Security Considerations¶
- Never commit sensitive values to source control
- Use environment variables for production deployments
- Rotate HMAC secret regularly
- Monitor verification logs for suspicious activity
- Limit bot permissions to only what's necessary
- Use HTTPS for all verification URLs