Step 20 of 18

Discord Bridge

Discord Bridge

Optional. Bridge your existing Discord server to Matrix for gradual migration.

This is advanced. You need:

  • A running KamenChat server
  • An admin account on Matrix
  • A Discord bot

Step 1: Create Discord Bot

  1. Go to discord.com/developers/applications
  2. Click New Application → Name it (e.g., “KamenChat Bridge”)
  3. Go to Bot tab → Click Add Bot
  4. Click Reset Token → Copy the token (save it!)
  5. Enable Privileged Gateway Intents:
    • ✅ PRESENCE INTENT
    • ✅ SERVER MEMBERS INTENT
    • ✅ MESSAGE CONTENT INTENT
  6. Save changes

Step 2: Run Bridge Setup

./scripts/setup-discord-bridge.sh

Enter your Discord bot token when prompted.

Step 3: Register the Bridge

  1. Open your Matrix client
  2. Go to the Admin room (you auto-joined when you created your account)
  3. Send this command with the registration file contents in a code block:
!admin appservices register
id: "discord"
url: "http://discord-bridge:9005"
as_token: "your-token-here"
hs_token: "your-token-here"
sender_localpart: "_discord_bot"
rate_limited: false
namespaces:
  users:
    - exclusive: true
      regex: '@_discord_.*'
  aliases:
    - exclusive: false
      regex: '#_discord_.*'
  rooms: []
  1. Confirm it worked:
!admin appservices list

Should show: Appservices (1): discord

Step 4: Start the Bridge

docker compose -f docker-compose.yml -f docker-compose.bridge.yml up -d discord-bridge

Check logs:

docker logs kamenchat-discord-bridge --tail=20

Look for: Discordbot started successfully

Step 5: Invite Bot to Discord

  1. Go back to discord.com/developers/applications
  2. Select your bot → OAuth2URL Generator
  3. Select bot scope
  4. Permissions: Administrator (easiest)
  5. Copy the generated URL
  6. Open URL → Select your server → Authorize

Step 6: Bridge a Channel

In Matrix:

  1. Create or open a room
  2. Invite the bridge bot: @_discord_bot:yourdomain.com
  3. Get your Discord server ID and channel ID:
    • Enable Developer Mode in Discord (Settings → Advanced)
    • Right-click server → Copy ID
    • Right-click channel → Copy ID
  4. In the Matrix room, type:
    !discord bridge SERVER_ID CHANNEL_ID
    

Done! Messages now flow both ways.

Commands

CommandDescription
!discord bridge <server> <channel>Bridge this room to a Discord channel
!discord unbridgeRemove bridge from this room

Troubleshooting

Bot not connecting? Check token is correct in config/discord-bridge/config.yaml

Messages not bridging? Make sure bot has Administrator permissions in Discord

Bridge crashing? Check logs: docker logs kamenchat-discord-bridge