Skip to content

Event Handling

Each gateway event is one method on EventHandler. You implement only the ones you care about; everything else has an empty default. Examples covering the non-message event surface:

Wiring

Each event family has its own intent flag. Forgetting the flag means the handler is silent, not an error. Mix the flags you need:

rust
let intents = Intents::new()
    .with_guild_members()                 // examples/events/guild_member.rs
    .with_open_forum_event()              // examples/events/open_forum.rs
    .with_audio_or_live_channel_member()  // examples/events/audio_or_live_channel_member.rs
    .with_public_messages();              // c2c/group manage events

Inside the handler, the session dereferences to BotApi, so you can react by calling APIs directly on session (for example, session.create_direct_message + session.send_direct_message to greet a new member). Group/C2C manage sessions also provide session.send_message(...) and fill event_id / msg_seq automatically when possible.

See also

Released under the MIT License.