#discord-rich-presence #discord #rich-presence #ipc

discord-ipc-rp

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

2 releases

0.1.1 Dec 29, 2023
0.1.0 Dec 29, 2023

#11 in #discord-rich-presence

Download history 76/week @ 2023-12-31 19/week @ 2024-01-28 5/week @ 2024-02-04 8/week @ 2024-02-18 11/week @ 2024-02-25 8/week @ 2024-03-10 43/week @ 2024-03-31 94/week @ 2024-04-07 91/week @ 2024-04-14

228 downloads per month

MIT license

38KB
768 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_ipc::{Result, activity, DiscordIpc, DiscordIpcClient};

fn main() -> Result<()> {
    let mut client = DiscordIpcClient::new("<some application ID>");

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

    std::thread::sleep(std::time::Duration::from_secs(5));

    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_ipc::{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.8MB
~40K SLoC