| Crates.io | discord-presence |
| lib.rs | discord-presence |
| version | 2.1.0 |
| created_at | 2022-04-17 01:37:49.472574+00 |
| updated_at | 2025-08-08 03:36:41.525284+00 |
| description | A Rust client for Discord RPC. |
| homepage | |
| repository | https://github.com/jewlexx/discord-presence.git |
| max_upload_size | |
| id | 569254 |
| size | 136,267 |
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
Add this to your Cargo.toml:
[dependencies]
discord-presence = "2.1"
or run:
cargo add discord-presence
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.
See CHANGELOG.md
See CONTRIBUTING.md