Update example

Clear presence if input is empty.
This commit is contained in:
Patrick Auernig 2018-04-08 21:08:20 +02:00
parent a9480b9d72
commit 6522a5b4a0
1 changed files with 16 additions and 10 deletions

View File

@ -34,8 +34,13 @@ fn main() {
let mut buf = String::new(); let mut buf = String::new();
io::stdin().read_line(&mut buf).unwrap(); io::stdin().read_line(&mut buf).unwrap();
buf.pop();
if buf.is_empty() {
if let Err(why) = drpc.clear_activity() {
println!("Failed to clear presence: {}", why);
}
} else {
if let Err(why) = drpc.set_activity(|a| a if let Err(why) = drpc.set_activity(|a| a
.state(buf) .state(buf)
.assets(|ass| ass .assets(|ass| ass
@ -46,5 +51,6 @@ fn main() {
{ {
println!("Failed to set presence: {}", why); println!("Failed to set presence: {}", why);
} }
}
}; };
} }