2022-02-03 09:52:53 -05:00
|
|
|
use discord_rpc_client::{models::Event, Client as DiscordRPC};
|
2018-04-10 08:26:41 -04:00
|
|
|
use simplelog::*;
|
2022-02-03 09:52:53 -05:00
|
|
|
use std::{thread, time};
|
2018-04-10 08:26:41 -04:00
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> discord_rpc_client::Result<()> {
|
|
|
|
TermLogger::init(
|
|
|
|
LevelFilter::Debug,
|
|
|
|
Config::default(),
|
|
|
|
TerminalMode::Mixed,
|
|
|
|
ColorChoice::Always,
|
|
|
|
)
|
|
|
|
.unwrap();
|
2018-04-10 08:26:41 -04:00
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
let drpc = DiscordRPC::default();
|
2018-04-10 08:26:41 -04:00
|
|
|
|
2022-02-03 15:56:37 -05:00
|
|
|
drpc.connect(425407036495495169).await?;
|
2018-04-10 08:26:41 -04:00
|
|
|
|
2022-02-03 09:52:53 -05:00
|
|
|
drpc.subscribe(Event::ActivityJoin, |j| j.secret("123456"))
|
2022-02-03 15:56:37 -05:00
|
|
|
.await
|
2018-04-10 08:26:41 -04:00
|
|
|
.expect("Failed to subscribe to event");
|
|
|
|
|
2022-02-03 09:52:53 -05:00
|
|
|
drpc.subscribe(Event::ActivitySpectate, |s| s.secret("123456"))
|
2022-02-03 15:56:37 -05:00
|
|
|
.await
|
2018-04-10 08:26:41 -04:00
|
|
|
.expect("Failed to subscribe to event");
|
|
|
|
|
|
|
|
drpc.subscribe(Event::ActivityJoinRequest, |s| s)
|
2022-02-03 15:56:37 -05:00
|
|
|
.await
|
2018-04-10 08:26:41 -04:00
|
|
|
.expect("Failed to subscribe to event");
|
|
|
|
|
|
|
|
drpc.unsubscribe(Event::ActivityJoinRequest, |j| j)
|
2022-02-03 15:56:37 -05:00
|
|
|
.await
|
2018-04-10 08:26:41 -04:00
|
|
|
.expect("Failed to unsubscribe from event");
|
|
|
|
|
2022-02-03 09:52:53 -05:00
|
|
|
loop {
|
2022-02-03 15:56:37 -05:00
|
|
|
tokio::time::sleep(time::Duration::from_millis(500)).await;
|
2022-02-03 09:52:53 -05:00
|
|
|
}
|
2018-04-10 08:26:41 -04:00
|
|
|
}
|