18 releases

0.5.14 Dec 16, 2022
0.5.12 Nov 7, 2022
0.5.5 Jul 8, 2022

#164 in Game dev

Download history 29/week @ 2022-12-09 81/week @ 2022-12-16 79/week @ 2022-12-23 17/week @ 2022-12-30 11/week @ 2023-01-06 13/week @ 2023-01-13 35/week @ 2023-01-20 38/week @ 2023-01-27 21/week @ 2023-02-03 62/week @ 2023-02-10 66/week @ 2023-02-17 24/week @ 2023-02-24 14/week @ 2023-03-03 51/week @ 2023-03-10 12/week @ 2023-03-17 13/week @ 2023-03-24

90 downloads per month
Used in bevy-discord-presence

MIT license

38KB
940 lines

Discord RPC

crates.io crates.io docs.rs

Discord RPC client for Rust forked from Discord RPC Client

Note: If you are looking to add this into a game, check out the Bevy implementation

Installation

Add this to your Cargo.toml:

[dependencies]
discord-presence = "0.5"

or run:

cargo add discord-presence

Example

use std::{env, thread, time};
use discord_presence::{Client, Event};

fn main() {
    // Get our main status message
    let state_message = env::args().nth(1).expect("Requires at least one argument");

    // Create the client
    let mut drpc = Client::new(1003450375732482138);

    // Register event handlers with the corresponding methods
    drpc.on_ready(|_ctx| {
        println!("ready?");
    });

    // or

    drpc.on_event(Event::Ready, |ctx| {
        println!("READY!");
    });

    // Start up the client connection, so that we can actually send and receive stuff
    drpc.start();

    // Set the activity
    drpc.set_activity(|act| act.state(state_message))
        .expect("Failed to set activity");

    // Wait 10 seconds before exiting
    thread::sleep(time::Duration::from_secs(10));
}

More examples can be found in the examples directory.

Changelog

See CHANGELOG.md

Contributions

See CONTRIBUTING.md

Dependencies

~2–40MB
~689K SLoC