From bfc48a986d543711c9a341b64f17bb81467e8a87 Mon Sep 17 00:00:00 2001 From: jellywx Date: Sun, 20 Dec 2020 14:36:20 +0000 Subject: [PATCH] added length check to timer creation --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/reminder_cmds.rs | 21 ++++++++++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 865557c..17e83b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1316,7 +1316,7 @@ dependencies = [ [[package]] name = "reminder_rs" -version = "1.3.0" +version = "1.3.1" dependencies = [ "Inflector", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 6ef579a..e011a7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reminder_rs" -version = "1.3.0" +version = "1.3.1" authors = ["jellywx "] edition = "2018" diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index d477e5a..32e1e40 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -719,12 +719,23 @@ async fn timer(ctx: &Context, msg: &Message, args: String) { .map(|s| s.to_string()) .unwrap_or(format!("New timer #{}", count + 1)); - Timer::create(&name, owner, &pool).await; + if name.len() <= 32 { + Timer::create(&name, owner, &pool).await; - let _ = msg - .channel_id - .say(&ctx, lm.get(&language, "timer/success")) - .await; + let _ = msg + .channel_id + .say(&ctx, lm.get(&language, "timer/success")) + .await; + } else { + let _ = msg + .channel_id + .say( + &ctx, + lm.get(&language, "timer/name_length") + .replace("{}", &name.len().to_string()), + ) + .await; + } } }