yet-another-discord-rpc

Crates.ioyet-another-discord-rpc
lib.rsyet-another-discord-rpc
version0.1.0
created_at2025-08-03 15:42:38.515676+00
updated_at2025-08-03 15:42:38.515676+00
descriptionExtremely simple, Discord Rich Presence client for Rust.
homepagehttps://github.com/aspicho/yet-another-discord-rich-presence
repositoryhttps://github.com/aspicho/yet-another-discord-rich-presence
max_upload_size
id1779837
size38,795
Daniil Mishchenko (aspicho)

documentation

https://docs.rs/yet-another-discord-rpc

README

Yet another Discord Rich Presence

This an extremely simple Discord Rich Presence client, currently supporting only unix. Tested only on macOS as I don't have any windows or linux pc's available for testing and development.

It supporsts starting, updating, clearing and stopping activities. Activity is described via json using serde_json::json macro.

Why?

There's a multiple other crates that implements Discord RPC and I'm aware of them, however none of them fully satisfied my requirements, because I wanted and needed something that would fit this criteria:

  • Be Async.
  • Use tokio for it's backend.
  • Doesn't implement any activity builders and accept plane json.
  • The last time it was updated was not 3 years ago.

I don't aim for it to be a replacement or competetor for any existing crate or project, the solo purpose of this project is to be a part of my other projects. However I'd be more than happy if it ended up being useful for anyone else, so feel free open issues and PR!

Example

use yet_another_discord_rpc::DiscordRpc;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    const CLIENT_ID: &str = "your_discord_app_client_id";

    let mut rpc = DiscordRpc::new(CLIENT_ID).await?;
    rpc.start_activity(None).await?;
    
    tokio::time::sleep(tokio::time::Duration::from_secs(6)).await;
    
    rpc.set_activity(
        json!({
            "details": "Playing a game",
            "state": "In main menu",
            "assets": {
                "large_image": "game_logo",
                "large_text": "My Game"
            }
        })
    ).await?;
    
    tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
    rpc.stop_activity().await?;
    
    Ok(())
}

Running the Example

To run the basic example:

cargo run -- <client_id>

To run with logging output:

RUST_LOG=info cargo run --features logging -- <client_id>

Optional logging support:

[dependencies]
yet-another-discord-rpc = { version = "0.1.0", features = ["logging"] }
Commit count: 0

cargo fmt