2018-03-22 10:35:48 -04:00
|
|
|
# Discord RPC Client
|
|
|
|
|
2022-02-03 18:40:32 -05:00
|
|
|
This is a fork of [https://gitlab.com/valeth/discord-rpc-client.rs](https://gitlab.com/valeth/discord-rpc-client.rs)
|
|
|
|
|
2018-03-22 10:35:48 -04:00
|
|
|
Discord RPC client for Rust
|
|
|
|
|
2018-12-05 19:27:39 -05:00
|
|
|
|
2018-03-22 10:35:48 -04:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
Add this to your `Cargo.toml`:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[dependencies]
|
2018-04-02 17:44:51 -04:00
|
|
|
discord-rpc-client = "^0.2"
|
2018-03-22 10:35:48 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2018-12-05 19:27:39 -05:00
|
|
|
## Example
|
|
|
|
|
|
|
|
```rust
|
|
|
|
extern crate discord_rpc_client;
|
|
|
|
|
|
|
|
use std::{env, thread, time};
|
|
|
|
use discord_rpc_client::Client;
|
|
|
|
|
|
|
|
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(425407036495495169);
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
2018-03-22 11:03:20 -04:00
|
|
|
|
2018-03-23 05:44:52 -04:00
|
|
|
## Contributions
|
|
|
|
|
|
|
|
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
|
|
|