Discord Messenger - Setup Guide
This guide covers setting up Discord Messenger for both webhook-only and full bot integration.
Webhook Setup (Recommended for Beginners)
Webhooks are the easiest way to send messages to Discord. No bot required!
-
Create a Webhook in Discord
- Open your Discord server
- Go to Server Settings → Integrations → Webhooks
- Click “New Webhook”
- Choose the target channel
- Copy the Webhook URL
-
Install the Plugin
Extract to
YourProject/Plugins/DiscordMessenger/Activate your license in Project Settings. -
Configure Default Webhook
In Project Settings → Plugins → gameDNA Discord Messenger:
- Paste your webhook URL in “Default Webhook URL”
- Set default username (optional)
- Set default avatar URL (optional)
-
Test It!
Create a simple Blueprint:
Event BeginPlay→ Send Discord MessageContent: "Hello from Unreal Engine!"→ On Success: Print "Message Sent!"
Sending Rich Embeds
// Create an embedCreate Discord Embed→ Set Title: "Player Achievement"→ Set Description: "A new achievement was unlocked!"→ Set Color: #FFD700 (Gold)→ Add Field: Name="Player", Value=PlayerName, Inline=true→ Add Field: Name="Achievement", Value=AchievementName, Inline=true→ Set Thumbnail: AchievementIconURL→ Set Footer: "gameDNA Achievement System"
// Send it→ Send Embed to Webhook (WebhookURL, Embed)Sending Files
// Take a screenshotTake Screenshot → Save to Disk → Get File Path
// Send with messageSend File to Webhook→ Webhook URL→ File Path: ScreenshotPath→ Message: "Check out this screenshot!"Bot Setup (Advanced Features)
For slash commands, reading messages, and more control, set up a Discord bot.
-
Create Discord Application
- Go to discord.com/developers/applications
- Click “New Application”
- Name it (e.g., “My Game Bot”)
-
Create Bot User
- Go to “Bot” section
- Click “Add Bot”
- Copy the Bot Token (keep this secret!)
- Enable required Intents:
- Message Content Intent (if reading messages)
- Server Members Intent (if accessing member info)
-
Invite Bot to Server
- Go to “OAuth2” → “URL Generator”
- Select scopes:
bot,applications.commands - Select permissions: Send Messages, Embed Links, Attach Files, etc.
- Copy and open the generated URL
- Select your server and authorize
-
Configure Plugin
In Project Settings → Plugins → gameDNA Discord Messenger:
Bot Token: YOUR_BOT_TOKENApplication ID: YOUR_APP_IDDefault Guild ID: YOUR_SERVER_ID (right-click server → Copy ID) -
Test Connection
Event BeginPlay→ Initialize Discord Bot→ On Success: Print "Bot Connected!"→ On Failure: Print Error
Slash Commands (v2.0)
Register slash commands for your game:
-
Define Command
Register Slash Command→ Name: "stats"→ Description: "View player statistics"→ Options:→ Add Option: Name="player", Type=String, Required=true -
Handle Command
On Slash Command Received (CommandName, Options, Interaction)→ Branch: CommandName == "stats"?→ True:→ Get Option Value "player" → PlayerName→ Query Stats for PlayerName→ Create Embed with Stats→ Respond to Interaction (Embed) -
Deploy Commands
// For testing (instant, guild-only)Sync Commands to Guild (GuildID)// For production (can take up to 1 hour to propagate)Sync Commands Globally
Interactive Buttons
Add buttons to your messages:
// Create message with buttonsCreate Action Row→ Add Button: Label="Accept", Style=Success, CustomID="accept_invite"→ Add Button: Label="Decline", Style=Danger, CustomID="decline_invite"
Create Discord Message→ Content: "You've been invited to a match!"→ Add Component: ActionRow
Send Bot Message (ChannelID, Message)
// Handle button clicksOn Button Interaction (CustomID, User, Interaction)→ Switch on CustomID: → "accept_invite": Process Accept → "decline_invite": Process Decline→ Acknowledge InteractionConfiguration Reference
Project Settings
| Setting | Description | Default |
|---|---|---|
Default Webhook URL | Webhook URL for quick sends | Empty |
Default Username | Display name for webhook messages | ”Game Bot” |
Default Avatar URL | Avatar image URL | Empty |
Bot Token | Discord bot token (keep secret!) | Empty |
Application ID | Discord application ID | Empty |
Default Guild ID | Server ID for guild commands | Empty |
Rate Limit Behavior | Queue or Drop when rate limited | Queue |
Max Queue Size | Maximum queued messages | 100 |
Enable Debug Logging | Log all Discord API calls | false |
Runtime Configuration
// C++ runtime configUDiscordMessengerSettings* Settings = GetMutableDefault<UDiscordMessengerSettings>();Settings->DefaultWebhookURL = "https://discord.com/api/webhooks/...";Settings->SaveConfig();// Blueprint runtime configSet Discord Default Webhook (NewURL)Set Discord Bot Token (NewToken)Best Practices
Security
- Never hardcode tokens - Use config files or environment variables
- Webhook URLs are secrets - Treat them like passwords
- Validate input - Don’t send user input directly to Discord
- Use HTTPS only - The plugin enforces this
Rate Limiting
Discord has rate limits. The plugin handles them automatically, but:
- Batch messages - Combine multiple updates into one message
- Use embeds - One embed can contain lots of information
- Cache frequently-used data - Don’t query Discord repeatedly
- Use webhooks for one-way - They have higher limits than bot endpoints
Performance
- Async everything - All Discord calls are async, never block
- Handle failures - Network calls can fail, always have fallbacks
- Limit file sizes - Discord has 8MB limit for files (25MB with Nitro)
Troubleshooting
| Issue | Solution |
|---|---|
| ”Invalid Webhook URL” | Ensure URL starts with https://discord.com/api/webhooks/ |
| ”401 Unauthorized” | Check bot token is correct and not expired |
| ”Missing Permissions” | Re-invite bot with required permissions |
| ”Rate Limited” | Reduce message frequency, plugin will queue automatically |
| Messages not appearing | Check bot has access to the channel |
Debug Mode
Enable debug logging to see all API calls:
- Project Settings → Discord Messenger → Enable Debug Logging
- Check Output Log for
LogDiscordMessengerentries
Next Steps
- Plugin Overview - Feature list
- FAQ - Common questions
- Discord API Docs - Official Discord documentation