Skip to content

Discord Channel

Connect your Moxxy agent to Discord as a bot.

Prerequisites

  1. A Discord account
  2. A Discord server where you have admin rights
  3. Access to the Discord Developer Portal

Setup

Step 1: Create a Discord Application

  1. Go to Discord Developer Portal
  2. Click New Application
  3. Give it a name (e.g., "Moxxy Bot")
  4. Note your Application ID

Step 2: Create a Bot User

  1. Go to Bot in the left sidebar
  2. Click Reset Token to generate a bot token
  3. Save the token -- you will not see it again

Step 3: Enable Privileged Gateway Intents

Under Bot > Privileged Gateway Intents, enable:

  • Message Content Intent (required -- Moxxy needs to read message content)

Step 4: Invite the Bot to Your Server

  1. Go to OAuth2 > URL Generator
  2. Select scopes:
    • bot
  3. Select permissions:
    • Send Messages
    • Read Message History
  4. Copy the generated URL
  5. Open in browser and invite to your server

Step 5: Store the Bot Token in the Vault

bash
curl -X POST http://localhost:3000/v1/vault/secrets \
  -H "Authorization: Bearer mox_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key_name": "DISCORD_BOT_TOKEN",
    "value": "YOUR_BOT_TOKEN",
    "policy_label": "channel"
  }'

Step 6: Create the Discord Channel

Via CLI:

bash
moxxy channel discord

Or via API:

bash
curl -X POST http://localhost:3000/v1/channels \
  -H "Authorization: Bearer mox_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "discord",
    "config": {
      "bot_token_secret_ref": "secret-ref-uuid"
    }
  }'

Step 7: Pair an Agent to a Server/Channel

bash
curl -X POST http://localhost:3000/v1/channels/pair \
  -H "Authorization: Bearer mox_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent-uuid",
    "channel_id": "discord-channel-uuid",
    "external_chat_id": "discord-channel-id-here"
  }'

Pairing works the same as Telegram -- pairing codes can also be used for manual binding.

Step 8: Test

Mention the bot or send a message in the paired Discord channel. The bound agent should respond.

How It Works

Moxxy's Discord transport connects to the Discord Gateway and listens for messages. When a message arrives in a paired channel, the transport looks up the channel binding to determine which agent handles it.

Channel Bindings

Bindings are stored in the channel_bindings table:

FieldDescription
agent_idThe agent handling this channel
channel_idThe Discord channel configuration
external_chat_idThe Discord channel/server ID

Required Bot Permissions

PermissionPurpose
Send MessagesRespond to users
Read Message HistorySee messages to respond to

Required Privileged Intents

IntentPurpose
Message Content IntentRead the content of messages (required)

Without the Message Content Intent enabled, the bot will not be able to read message content and will not function correctly.

Usage

Mentioning the Bot

The bot responds when mentioned:

@MoxxyBot What can you do?

Direct Messages

DM the bot directly for private conversations.

Server Integration

The bot operates within the Discord server where it has been invited and paired.

Troubleshooting

Bot Not Responding

  1. Verify the gateway is running on port 3000
  2. Check that the channel was created: GET /v1/channels
  3. Verify a binding exists for your Discord channel ID
  4. Confirm the bot token in the vault is valid
  5. Check that Message Content Intent is enabled in the Developer Portal

Missing Permissions

Error: Missing Permissions
  1. Verify the bot role has Send Messages and Read Message History permissions
  2. Check role hierarchy in the server
  3. Re-invite the bot with the correct permissions

Intents Error

Error: Privileged intent not enabled
  1. Go to the Discord Developer Portal
  2. Navigate to your application > Bot
  3. Enable Message Content Intent under Privileged Gateway Intents
  4. Save and restart the gateway

Bot Keeps Disconnecting

  1. Check network connectivity
  2. Verify the bot token is still valid
  3. Check the Discord status page for outages
  4. Review gateway logs

Security

  • Bot tokens are stored in the vault, encrypted at rest
  • Pairing ensures only authorized channels are bound to agents
  • Use vault grants to control which agents can access the bot token
  • Rotate bot tokens periodically via the Discord Developer Portal

Open source · Self-hosted · Data sovereign