28个版本 (6个稳定版)
| 新 1.3.0 | 2024年8月23日 | 
|---|---|
| 1.2.0 | 2024年5月1日 | 
| 1.1.2 | 2024年4月11日 | 
| 1.1.1 | 2024年3月13日 | 
| 0.5.5 | 2022年7月8日 | 
268 在 网络编程
每月下载 1,479 次
被  4 个包 使用
60KB
 1.5K  SLoC
Discord RPC
从Discord RPC客户端分叉的Rust Discord RPC客户端
注意:如果您想将其添加到游戏中,请查看Bevy实现
安装
将以下内容添加到您的 Cargo.toml
[dependencies]
discord-presence = "1.3"
或者运行
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));
}
更多示例可以在示例目录中找到。
变更日志
贡献
依赖项
~6–31MB
~462K SLoC