discord-rich-presence

Crates.iodiscord-rich-presence
lib.rsdiscord-rich-presence
version0.2.5
sourcesrc
created_at2021-05-29 17:15:45.011105
updated_at2024-09-28 20:34:52.506946
descriptionA simple, cross-platform crate for interfacing with Discord's IPC
homepage
repositoryhttps://github.com/vionya/discord-rich-presence
max_upload_size
id403561
size33,066
Violet (vionya)

documentation

https://docs.rs/discord-rich-presence

README

Discord Rich Presence

crates.io Docs

A simple, cross-platform crate to connect and send data to Discord's IPC. Special attention is given to sending rich presence data.

Example

use discord_rich_presence::{activity, DiscordIpc, DiscordIpcClient};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = DiscordIpcClient::new("<some application ID>")?;

    client.connect()?;
    client.set_activity(activity::Activity::new()
        .state("foo")
        .details("bar")
    )?;
    client.close()?;

    Ok(())
}

Running example on the CLI

The repository comes with an example you can run with cargo to set a dummy activity. Just provide a valid Client ID as the argument:

cargo run --example presence <CLIENT_ID>
Commit count: 71

cargo fmt