Discord is a popular platform for communities and gaming. Moltbot connects to Discord using the Bot API via channels.discord.js, providing DMs, server channels, and rich Discord features.

Quick Setup

Setting up Discord requires creating a bot application:

  1. Create bot application in Discord Developer Portal
  2. Get your bot token
  3. Invite bot to your server
  4. Configure in Moltbot
  5. Start chatting!

Creating a Discord Bot

Step 1: Create Application

  1. Go to Discord Developer Portal
  2. Click "New Application"
  3. Enter a name for your bot
  4. Click "Create"

Step 2: Create Bot

  1. Go to "Bot" section
  2. Click "Add Bot"
  3. Confirm creation
  4. Copy the bot token

Step 3: Configure Bot

Set bot options:

  • Enable "Message Content Intent" (required)
  • Set bot username and avatar
  • Configure other settings as needed

Inviting Bot to Server

Step 1: Generate Invite URL

  1. Go to "OAuth2" → "URL Generator"
  2. Select "bot" scope
  3. Select permissions:
    • Send Messages
    • Read Message History
    • Use Slash Commands (optional)
    • Attach Files
    • Embed Links
  4. Copy the generated URL

Step 2: Invite Bot

  1. Open the invite URL
  2. Select your server
  3. Authorize the bot
  4. Bot should appear in your server

Configuring Moltbot

Basic Configuration

Discord Config
{
  "channels": {
    "discord": {
      "enabled": true,
      "token": "YOUR_BOT_TOKEN_HERE"
    }
  }
}

Setting Token

Add your bot token:

  1. Get token from Discord Developer Portal
  2. Add to configuration file
  3. Or set via environment variable: DISCORD_BOT_TOKEN

Discord Features

Direct Messages

  • Send and receive DMs
  • Rich embeds
  • File attachments
  • Reactions

Server Channels

  • Join text channels
  • Mention-based activation (default)
  • Channel allowlists
  • Reply threading
  • Rich embeds

Media Support

  • Images and attachments
  • File uploads
  • Rich embeds
  • Reactions

Advanced Configuration

Server Configuration

Server Config
{
  "channels": {
    "discord": {
      "guilds": {
        "123456789012345678": {
          "channels": ["general", "support"]
        }
      }
    }
  }
}

Channel Configuration

Channel Config
{
  "channels": {
    "discord": {
      "guilds": {
        "123456789012345678": {
          "channels": {
            "general": {
              "requireMention": true
            },
            "support": {
              "requireMention": false,
              "activation": "always"
            }
          }
        }
      }
    }
  }
}

Security & Permissions

Bot Permissions

Required permissions:

  • Send Messages
  • Read Message History
  • Attach Files
  • Embed Links
  • Use External Emojis (optional)

Bot Token Security

Keep your bot token secure:

  • Never share your token
  • Store in configuration file
  • Use environment variables if needed
  • Regenerate token if compromised

Troubleshooting Discord

Bot Not Responding

If bot doesn't respond:

  1. Verify bot token is correct
  2. Check Gateway is running
  3. Verify bot is online in Discord
  4. Check bot permissions
  5. Review Gateway logs

Can't Read Messages

If bot can't read messages:

  1. Check "Message Content Intent" is enabled
  2. Verify bot permissions
  3. Check channel permissions
  4. Ensure bot is in the channel

Permission Errors

If you get permission errors:

  1. Check bot role permissions
  2. Verify channel permissions
  3. Re-invite bot with correct permissions
  4. Check bot's role position

Best Practices

  • Use Channel Allowlists - Control which channels bot can access
  • Enable Mention Gating - For server channels
  • Secure Token - Keep bot token private
  • Set Proper Permissions - Only grant needed permissions
  • Monitor Logs - Check for issues

Next Steps