Discord Rich Presence in Rust, with 1st party Bevy support
Find a file
Juliette e17c4c66fc
Some checks failed
Rust / build (macos-latest) (push) Has been cancelled
Rust / build (ubuntu-latest) (push) Has been cancelled
Rust / build (windows-latest) (push) Has been cancelled
Merge pull request #138 from jewlexx/blocking-socket
2025-06-09 16:17:17 +10:00
.github Update actions/checkout action to v4 2023-10-19 10:45:45 +00:00
.vscode fix activity type doc warnings 2024-08-23 11:52:54 +10:00
examples minor fixes 2024-12-20 13:34:26 +11:00
src set unix socket to be blocking 2025-06-09 15:52:50 +10:00
tests Add a seperate ActivityType test 2024-08-23 11:41:52 +10:00
.editorconfig updated editorconfig and formatted md files 2022-04-21 17:15:13 +10:00
.gitignore fixes 2022-04-17 10:45:06 +10:00
Cargo.toml removed std feature from quork 2025-04-29 10:41:42 +10:00
CHANGELOG.md updated changelog 2025-04-29 10:45:04 +10:00
CONTRIBUTING.md updated contributions and overcommit 2022-04-21 17:12:49 +10:00
LICENSE bump license 2022-04-17 11:30:59 +10:00
README.md bump readme version 2025-04-29 10:25:30 +10:00
renovate.json Add renovate.json 2022-06-28 12:42:00 +00:00

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 = "1.6"

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