Skip to content

Discord Messenger - Setup Guide

This guide covers setting up Discord Messenger for both webhook-only and full bot integration.

Webhooks are the easiest way to send messages to Discord. No bot required!

  1. 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
  2. Install the Plugin

    Extract to YourProject/Plugins/DiscordMessenger/ Activate your license in Project Settings.

  3. 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)
  4. Test It!

    Create a simple Blueprint:

    Event BeginPlay
    → Send Discord Message
    Content: "Hello from Unreal Engine!"
    → On Success: Print "Message Sent!"

Sending Rich Embeds

// Create an embed
Create 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 screenshot
Take Screenshot → Save to Disk → Get File Path
// Send with message
Send 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.

  1. Create Discord Application

  2. 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)
  3. 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
  4. Configure Plugin

    In Project Settings → Plugins → gameDNA Discord Messenger:

    Bot Token: YOUR_BOT_TOKEN
    Application ID: YOUR_APP_ID
    Default Guild ID: YOUR_SERVER_ID (right-click server → Copy ID)
  5. 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:

  1. Define Command

    Register Slash Command
    → Name: "stats"
    → Description: "View player statistics"
    → Options:
    → Add Option: Name="player", Type=String, Required=true
  2. 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)
  3. 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 buttons
Create 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 clicks
On Button Interaction (CustomID, User, Interaction)
→ Switch on CustomID:
→ "accept_invite": Process Accept
→ "decline_invite": Process Decline
→ Acknowledge Interaction

Configuration Reference

Project Settings

SettingDescriptionDefault
Default Webhook URLWebhook URL for quick sendsEmpty
Default UsernameDisplay name for webhook messages”Game Bot”
Default Avatar URLAvatar image URLEmpty
Bot TokenDiscord bot token (keep secret!)Empty
Application IDDiscord application IDEmpty
Default Guild IDServer ID for guild commandsEmpty
Rate Limit BehaviorQueue or Drop when rate limitedQueue
Max Queue SizeMaximum queued messages100
Enable Debug LoggingLog all Discord API callsfalse

Runtime Configuration

// C++ runtime config
UDiscordMessengerSettings* Settings = GetMutableDefault<UDiscordMessengerSettings>();
Settings->DefaultWebhookURL = "https://discord.com/api/webhooks/...";
Settings->SaveConfig();
// Blueprint runtime config
Set Discord Default Webhook (NewURL)
Set Discord Bot Token (NewToken)

Best Practices

Security

  1. Never hardcode tokens - Use config files or environment variables
  2. Webhook URLs are secrets - Treat them like passwords
  3. Validate input - Don’t send user input directly to Discord
  4. Use HTTPS only - The plugin enforces this

Rate Limiting

Discord has rate limits. The plugin handles them automatically, but:

  1. Batch messages - Combine multiple updates into one message
  2. Use embeds - One embed can contain lots of information
  3. Cache frequently-used data - Don’t query Discord repeatedly
  4. Use webhooks for one-way - They have higher limits than bot endpoints

Performance

  1. Async everything - All Discord calls are async, never block
  2. Handle failures - Network calls can fail, always have fallbacks
  3. Limit file sizes - Discord has 8MB limit for files (25MB with Nitro)

Troubleshooting

IssueSolution
”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 appearingCheck bot has access to the channel

Debug Mode

Enable debug logging to see all API calls:

  1. Project Settings → Discord Messenger → Enable Debug Logging
  2. Check Output Log for LogDiscordMessenger entries

Next Steps