Skip to main content
This document provides a comprehensive breakdown of how events flow through the Discord plugin system.

Complete Event Flow Diagram

Detailed Event Flows

1. Message Processing Flow

2. Voice Channel Flow

3. Slash Command Flow

4. Attachment Processing Flow

5. Multi-Server Event Flow

Event Type Reference

Discord.js Events

elizaOS Events Emitted

State Management

Message Context

Voice Context

Error Handling in Event Flow

Error Propagation

Performance Considerations

Event Batching

For high-volume servers, events are batched:

Connection Pooling

Voice connections are pooled to reduce overhead:

Monitoring Event Flow

Event Metrics

Track event processing metrics:

Best Practices

  1. Event Debouncing
    • Debounce rapid events (typing indicators, voice state)
    • Batch similar events when possible
  2. Error Isolation
    • Don’t let one event error affect others
    • Use try-catch at event handler level
  3. Resource Management
    • Clean up event listeners on disconnect
    • Limit concurrent event processing
  4. Monitoring
    • Track event processing times
    • Monitor error rates by event type
    • Alert on unusual patterns