Skip to content

Commit

Permalink
fixed a couple of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayrsn committed Aug 23, 2022
1 parent 8e9f7d6 commit 700a06a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "discord-rpc-cli"
version = "1.4.0"
version = "1.4.1"
edition = "2021"
authors = ["Rayr <https://rayr.ml/LinkInBio>"]
description = "A Discord RPC cli client written purely in Rust"
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub(crate) struct Cli {
#[clap(short = 'a', long = "afk",help = "Whether to enable AFK RPC or not) (optional)",display_order=20)]
pub afk_rpc: bool,

#[clap(short = 'f', long = "afk_after",help = "How many seconds should pass after the AFK RPC is started [In Seconds] (optional)",default_value="5",display_order=21)]
#[clap(short = 'f', long = "afk_after",help = "How many minutes should pass after the AFK RPC is started [In Minutes] (optional)",default_value="5",display_order=21)]
pub afk_after: i64,

#[clap(short = 'k', long = "afk_update",help = "How often to check wether the user is idle or not [In Seconds](optional)",default_value="20",display_order=22)]
Expand Down
11 changes: 5 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,20 @@ For more information try --help");
if args.disable_color == false {
println!("{}{}", "AFK RPC".magenta(), " is enabled.");
if afk_after == 1 {
println!("{}{}{}", "Will AFK after ",afk_after.to_string().magenta(), " second.");
println!("{}{}{}", "Will AFK after ",afk_after.to_string().magenta(), " minute.");
} else if afk_after == 0 {
println!("{}{}", "Will AFK ","immediately".magenta());
} else {
println!("{}{}{}", "Will AFK after ",afk_after.to_string().magenta(), " seconds.");
println!("{}{}{}", "Will AFK after ",afk_after.to_string().magenta(), " minutes.");
}
} else {
println!("AFK RPC is enabled.");
if afk_after == 1 {
println!("{}{}{}", "Will AFK after ",afk_after.to_string(), " second.");
println!("{}{}{}", "Will AFK after ",afk_after.to_string(), " minute.");
} else if afk_after == 0 {
println!("{}", "Will AFK immediately.");
} else {
println!("{}{}{}", "Will AFK after ",afk_after.to_string(), " seconds.");
println!("{}{}{}", "Will AFK after ",afk_after.to_string(), " minutes.");
}
}

Expand All @@ -268,8 +268,7 @@ For more information try --help");
loop {
thread::sleep(Duration::from_secs(afk_update.try_into().expect("Failed to convert to seconds")));
let idle = UserIdle::get_time().expect("Failed to get idle time");
println!("{}", idle.as_seconds());
if idle.as_seconds() >= afk_after.try_into().expect("Couldn't convert afk_after to u64") {
if idle.as_minutes() >= afk_after.try_into().expect("Couldn't convert afk_after to u64") {
client.connect().expect("Failed to connect to Discord");

match idle.as_seconds() {
Expand Down

0 comments on commit 700a06a

Please sign in to comment.