Back to Eliza

Discord Connector

packages/docs/connectors/discord.md

2.0.19.8 KB
Original Source

Discord Connector

Connect your agent to Discord servers and DMs using the @elizaos/plugin-discord package.

Prerequisites

  • A Discord bot token from the Discord Developer Portal
  • The bot added to your target server(s) with appropriate permissions

Configuration

NameRequiredDescription
DISCORD_API_TOKENYesDiscord bot token for authentication
DISCORD_APPLICATION_IDNoApplication ID (auto-resolved from bot token if omitted)
CHANNEL_IDSNoComma-separated list of channel IDs to restrict the bot to
DISCORD_LISTEN_CHANNEL_IDSNoComma-separated list of channel IDs where the bot only listens (no responses)
DISCORD_SHOULD_IGNORE_BOT_MESSAGESNoIf true, ignore messages from other bots
DISCORD_SHOULD_IGNORE_DIRECT_MESSAGESNoIf true, ignore direct messages
DISCORD_SHOULD_RESPOND_ONLY_TO_MENTIONSNoIf true, only respond when explicitly @mentioned
DISCORD_VOICE_CHANNEL_IDNoVoice channel ID for the bot to join
DISCORD_TEST_CHANNEL_IDNoChannel ID for test suite operations

The connector auto-enables when token, botToken, or apiKey is truthy in the connector config and enabled is not explicitly false.

Configure in ~/.eliza/eliza.json:

json
{
  "connectors": {
    "discord": {
      "token": "your-discord-bot-token"
    }
  }
}
<Warning> Use the `token` field for your bot token. The auto-enable detection accepts `token`, `botToken`, or `apiKey`, but the Discord config schema only validates `token` as a known field. Using `botToken` will trigger auto-enable but may fail schema validation. </Warning>

Disabling the Connector

To explicitly disable the connector even when a token is present:

json
{
  "connectors": {
    "discord": {
      "token": "your-discord-bot-token",
      "enabled": false
    }
  }
}

Features

The plugin-auto-enable.ts module checks connectors.discord in your config. If token (or botToken / apiKey) is truthy and enabled is not explicitly false, the runtime automatically loads @elizaos/plugin-discord.

No environment variable is required to trigger auto-enable — it is driven entirely by the connector config object.

Environment Variables

When loaded, secrets are pushed to process.env for the plugin to consume:

VariableRequiredDescription
DISCORD_API_TOKENYesPrimary bot token (always set from token config field)
DISCORD_BOT_TOKENNoMirror of DISCORD_API_TOKEN (both always set)
DISCORD_APPLICATION_IDNoApplication ID. Auto-resolved via Discord OAuth2 API if not set
CHANNEL_IDSNoComma-separated list of channel IDs to restrict the bot to
DISCORD_LISTEN_CHANNEL_IDSNoComma-separated list of channel IDs where the bot will only listen (not respond)
DISCORD_VOICE_CHANNEL_IDNoVoice channel ID the bot should join (auto-selects based on activity if not set)
DISCORD_SHOULD_IGNORE_BOT_MESSAGESNoIgnore messages from other bots
DISCORD_SHOULD_IGNORE_DIRECT_MESSAGESNoIgnore direct messages
DISCORD_SHOULD_RESPOND_ONLY_TO_MENTIONSNoOnly respond when explicitly @mentioned

Note: If DISCORD_APPLICATION_ID is not configured, the runtime automatically resolves it by calling https://discord.com/api/v10/oauth2/applications/@me with the bot token.

Full Configuration Reference

All fields are set under connectors.discord in eliza.json.

FieldTypeDefaultDescription
tokenstringBot token (legacy field name)
namestringAccount display name
enabledbooleanExplicitly enable/disable
capabilitiesstring[]Capability flags
allowBotsbooleanAllow bot-authored messages to trigger responses
groupPolicy"open" | "disabled" | "allowlist""allowlist"How the bot joins group conversations
historyLimitinteger >= 0Max messages to include in conversation context
dmHistoryLimitinteger >= 0History limit for DM conversations
dmsobjectPer-DM history overrides keyed by DM ID. Each value: {historyLimit?: int}
textChunkLimitinteger > 0Max characters per message chunk
chunkMode"length" | "newline"How to split long messages
blockStreamingbooleanDisable streaming responses
blockStreamingCoalesceobjectCoalescing settings: minChars, maxChars, idleMs
maxLinesPerMessageinteger > 017Max lines per Discord message
mediaMaxMbnumber > 0Max media file size in MB
replyToMode"off" | "first" | "all"When to use Discord reply threading
configWritesbooleantrueAllow config writes from Discord events
markdownobjectMarkdown rendering: tables can be "off", "bullets", or "code"
commandsobjectnative and nativeSkills slash command toggles (boolean or "auto")

Retry Configuration

FieldTypeDescription
retry.attemptsintegerMax retry attempts
retry.minDelayMsintegerMinimum delay between retries
retry.maxDelayMsintegerMaximum delay between retries
retry.jitternumberJitter factor for retry backoff

Actions

Toggle individual Discord actions under actions:

FieldTypeDescription
actions.reactionsbooleanSend reactions
actions.stickersbooleanSend stickers
actions.emojiUploadsbooleanUpload custom emoji
actions.stickerUploadsbooleanUpload custom stickers
actions.pollsbooleanCreate polls
actions.permissionsbooleanManage permissions
actions.messagesbooleanSend messages
actions.threadsbooleanCreate/manage threads
actions.pinsbooleanPin messages
actions.searchbooleanSearch messages
actions.memberInfobooleanView member info
actions.roleInfobooleanView role info
actions.rolesbooleanManage roles
actions.channelInfobooleanView channel info
actions.voiceStatusbooleanVoice channel status
actions.eventsbooleanManage server events
actions.moderationbooleanModeration actions
actions.channelsbooleanManage channels
actions.presencebooleanPresence updates

DM Policy

Configure DM behavior under the dm key:

FieldTypeDefaultDescription
dm.enabledbooleanEnable/disable DMs
dm.policy"pairing" | "allowlist" | "open" | "disabled""pairing"DM access policy. "pairing" requires the pairing flow. "open" requires allowFrom to include "*"
dm.allowFrom(string|number)[]User IDs allowed to DM. Must include "*" when policy is "open"
dm.groupEnabledbooleanEnable group DMs
dm.groupChannels(string|number)[]Allowed group DM channel IDs

Guild Configuration

Per-guild settings under guilds.<guild-id>:

FieldTypeDescription
slugstringGuild display name
requireMentionbooleanOnly respond when @mentioned
toolsToolPolicySchemaTool access policy
toolsBySenderobjectPer-sender tool policies (keyed by sender ID)
reactionNotifications"off" | "own" | "all" | "allowlist"Reaction notification filter
users(string|number)[]Allowed user IDs

Channel Configuration

Per-channel settings under guilds.<guild-id>.channels.<channel-id>:

FieldTypeDescription
allowbooleanAllow bot in this channel
enabledbooleanEnable/disable channel
requireMentionbooleanOnly respond when @mentioned
toolsToolPolicySchemaTool access policy for this channel
toolsBySenderobjectPer-sender tool policies (keyed by sender ID)
skillsstring[]Skills allowed in this channel
users(string|number)[]Allowed user IDs
systemPromptstringChannel-specific system prompt override
autoThreadbooleanAuto-create threads for conversations

Advanced Features

Privileged Intents

json
{
  "connectors": {
    "discord": {
      "intents": {
        "presence": true,
        "guildMembers": true
      }
    }
  }
}

These must also be enabled in the Discord Developer Portal.

PluralKit Integration

json
{
  "connectors": {
    "discord": {
      "pluralkit": {
        "enabled": true,
        "token": "pk-token"
      }
    }
  }
}

Resolves PluralKit proxy messages to their original authors.

Exec Approvals

json
{
  "connectors": {
    "discord": {
      "execApprovals": {
        "enabled": true,
        "approvers": ["user-id-1"],
        "agentFilter": "pattern",
        "sessionFilter": "pattern"
      }
    }
  }
}

Requires human approval for certain agent actions.

Heartbeat

json
{
  "connectors": {
    "discord": {
      "heartbeat": {
        "showOk": true,
        "showAlerts": true,
        "useIndicator": true
      }
    }
  }
}

Multi-Account Support

The accounts field allows running multiple Discord bot accounts:

json
{
  "connectors": {
    "discord": {
      "accounts": {
        "bot-1": { "token": "...", "guilds": { } },
        "bot-2": { "token": "...", "guilds": { } }
      }
    }
  }
}

Each account inherits the base config and can override any field.