added length check to timer creation

This commit is contained in:
jellywx 2020-12-20 14:36:20 +00:00
parent 632d01f503
commit bfc48a986d
3 changed files with 18 additions and 7 deletions

2
Cargo.lock generated
View File

@ -1316,7 +1316,7 @@ dependencies = [
[[package]] [[package]]
name = "reminder_rs" name = "reminder_rs"
version = "1.3.0" version = "1.3.1"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"async-trait", "async-trait",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reminder_rs" name = "reminder_rs"
version = "1.3.0" version = "1.3.1"
authors = ["jellywx <judesouthworth@pm.me>"] authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018" edition = "2018"

View File

@ -719,12 +719,23 @@ async fn timer(ctx: &Context, msg: &Message, args: String) {
.map(|s| s.to_string()) .map(|s| s.to_string())
.unwrap_or(format!("New timer #{}", count + 1)); .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 let _ = msg
.channel_id .channel_id
.say(&ctx, lm.get(&language, "timer/success")) .say(&ctx, lm.get(&language, "timer/success"))
.await; .await;
} else {
let _ = msg
.channel_id
.say(
&ctx,
lm.get(&language, "timer/name_length")
.replace("{}", &name.len().to_string()),
)
.await;
}
} }
} }