Serenity is a Rust library for the Discord API.
Serenity solves the problem of building Discord bots and applications in Rust by providing a complete wrapper around Discord's API. The library handles the complexity of the gateway protocol transparently, automatically managing sharded connections without requiring explicit configuration. It includes a built-in cache that is updated automatically as events arrive, and this cache is consulted before making HTTP requests to avoid unnecessary API calls. Developers implement event handlers by defining a trait with methods corresponding to Discord events, and the library dispatches incoming events to these handlers with a context object containing relevant information.
Serenity suits developers building Discord bots in Rust who want low-level control over the API. For those preferring a higher-level command framework, the project recommends poise, which is built on top of serenity. For voice functionality, the project points to songbird as a companion library. The library provides examples demonstrating basic functionality, and the README emphasizes that while the documentation aims to be accurate, Discord's official documentation should be consulted for authoritative information.
The project maintains a stable minimum supported Rust version on its main branch, committing to support that version until the next major release. The next development branch tracks the latest Rust release, allowing the team to adopt new language features and reduce technical debt before those features become the baseline for the stable branch. The library offers granular feature flags allowing developers to customize which components to include, with sensible defaults covering the core functionality of builder, cache, client, gateway, HTTP, and model handling.