Skip to main content

timed_sync/
timed-sync.rs

1use std::{thread::sleep, time::Duration};
2
3use filthy_rich::DiscordIPCSync;
4
5fn main() {
6    let mut client = DiscordIPCSync::new("1463450870480900160").unwrap();
7
8    // first run
9    client.run().unwrap();
10
11    client.set_activity("this runs", "for ten seconds").unwrap();
12    sleep(Duration::from_secs(5));
13    client.set_activity("believe it", "or not").unwrap();
14    sleep(Duration::from_secs(5));
15
16    client.clear_activity().unwrap();
17
18    // if you want to drop the connection here:
19    // client.close().unwrap();
20
21    // optional sleep
22    sleep(Duration::from_secs(2));
23
24    // if you closed the connection, you must run it afterwards:
25    // client.run().unwrap();
26
27    // 2nd run
28    client.set_activity("this is the", "second run").unwrap();
29    sleep(Duration::from_secs(5));
30    client
31        .set_activity("which also runs", "for ten seconds")
32        .unwrap();
33    sleep(Duration::from_secs(5));
34}