A Discord plugin implementation for ElizaOS, enabling rich integration with Discord servers for managing interactions, voice, and message handling.
- Handle server join events and manage initial configurations
- Voice event management via the voice manager
- Manage and process new messages with the message manager
- Slash command registration and interaction handling
- Support for Discord attachments and media files
- Voice channel join/leave functionality
- Conversation summarization
- Media transcription capabilities
- Channel state and voice state providers
- Channel restriction support (limit bot to specific channels)
- Robust permissions management for bot functionality
- Event-driven architecture with comprehensive event handling
As this is a workspace package, it's installed as part of the ElizaOS monorepo:
bun installThe plugin requires the following environment variables:
# Discord API Credentials (Required)
DISCORD_APPLICATION_ID=your_application_id
DISCORD_API_TOKEN=your_api_token
# Optional Settings
# Comma-separated list of Discord channel IDs to restrict the bot to.
# If not set, the bot operates in all channels as usual.
CHANNEL_IDS=123456789012345678,987654321098765432const character = {
"plugins": [
...otherPlugins,
"@elizaos/plugin-discord"
]
}The plugin provides the following actions:
- chatWithAttachments - Handle messages with Discord attachments
- downloadMedia - Download media files from Discord messages
- joinVoice - Join a voice channel
- leaveVoice - Leave a voice channel
- summarize - Summarize conversation history
- transcribeMedia - Transcribe audio/video media to text
The plugin includes two state providers:
- channelStateProvider - Provides state information about Discord channels
- voiceStateProvider - Provides state information about voice channels
The plugin emits the following Discord-specific events:
GUILD_MEMBER_ADD- When a new member joins a guildGUILD_CREATE- When the bot joins a guildMESSAGE_CREATE- When a message is createdINTERACTION_CREATE- When an interaction is createdREACTION_RECEIVED- When a reaction is added to a message
-
DiscordService
- Main service class that extends ElizaOS Service
- Handles authentication and session management
- Manages Discord client connection
- Processes events and interactions
-
MessageManager
- Processes incoming messages and responses
- Handles attachments and media files
- Supports message formatting and templating
- Manages conversation context
-
VoiceManager
- Manages voice channel interactions
- Handles joining and leaving voice channels
- Processes voice events and audio streams
- Integrates with transcription services
-
Attachment Handler
- Downloads and processes Discord attachments
- Supports various media types
- Integrates with media transcription
The plugin includes a test suite (DiscordTestSuite) for validating functionality.
- Ensure that your
.envfile includes the requiredDISCORD_API_TOKENfor proper functionality - The bot requires appropriate Discord permissions to function correctly (send messages, connect to voice channels, etc.)
- If no token is provided, the plugin will load but remain non-functional with appropriate warnings
- The plugin uses Discord.js v14.18.0 with comprehensive intent support