#discord #rich-presence #ipc #rpc #events #event-listener

discordipc

A Rust crate that enables connection and interaction with Discord's IPC, allowing you to set custom activities for your project

2 releases

0.1.1 Mar 15, 2025
0.1.0 Mar 15, 2025

#1458 in Network programming

Download history 232/week @ 2025-03-12

232 downloads per month

MIT/Apache

51KB
653 lines

Crates.io License

πŸ“‘ Discord IPC

discordipc is a Rust library that enables connection and interaction with Discord's IPC, allowing you to set custom activities for your project.

⭐ Features

βœ… Rich Presence: Set custom activities, statuses, and more.
βœ… Event listeners: Handle Discord responses dynamically with event listeners.
βœ… Custom Packets: Extend functionality for advanced interactions.

πŸš€ Installation

Add the following to your Cargo.toml:

[dependencies]
discordipc = "0.1.1"

Or run:

cargo add discordipc

πŸ”§ Basic usage

use discordipc::{activity::Activity, packet::Packet, Client};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new_simple("<application_id>");

    client.connect_and_wait()?.filter()?;

    let activity = Activity::new().details("Some activity");
    let activity_packet = Packet::new_activity(Some(&activity), None);

    match client.send_and_wait(activity_packet)?.filter() {
        Ok(_packet) => println!("Activity has been set!"),
        Err(e) => println!("Couldn't set activity: {}", e),
    }

    println!("Press ENTER to exit...");
    std::io::stdin().read_line(&mut String::new()).unwrap();
    client.disconnect()?;
    println!("Disconnected");

    Ok(())
}

πŸ”Ž Examples

All usage examples are located in the examples folder. You can run an example by executing:

cargo run --example <example_name>

Replace <example_name> with the name of the example file you wish to try.

🀝 Contributing

This is a small project and all contributions are widely appreciated! Any help whether it's improving the documentation, fixing bugs, adding new features, or sharing ideas is welcome.
Don’t forget to leave a ⭐ if you find the library useful!

Dependencies

~1.5–2.5MB
~52K SLoC