#rich-presence #discord #ipc

discord-rich-presence

A simple, cross-platform crate for interfacing with Discord's IPC

12 releases

0.2.3 Sep 17, 2022
0.2.2 Aug 8, 2022
0.2.1 Jul 7, 2022
0.2.0 Mar 8, 2022
0.1.5 May 31, 2021

#264 in Operating systems

Download history 695/week @ 2023-11-20 558/week @ 2023-11-27 646/week @ 2023-12-04 659/week @ 2023-12-11 463/week @ 2023-12-18 617/week @ 2023-12-25 618/week @ 2024-01-01 654/week @ 2024-01-08 992/week @ 2024-01-15 938/week @ 2024-01-22 714/week @ 2024-01-29 663/week @ 2024-02-05 879/week @ 2024-02-12 1001/week @ 2024-02-19 854/week @ 2024-02-26 708/week @ 2024-03-04

3,585 downloads per month
Used in 13 crates (11 directly)

MIT license

24KB
466 lines

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(())
}

lib.rs:

This library provides easy access to the Discord IPC.

It provides implementations for both Unix and Windows operating systems, with both implementations using the same API. Thus, this crate can be used in a platform-agnostic manner.

Hello world

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

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

    let payload = activity::Activity::new().state("Hello world!");
    client.set_activity(payload)?;
}

Dependencies

~1–1.9MB
~40K SLoC