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]]
name = "reminder_rs"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"Inflector",
"async-trait",

View File

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

View File

@ -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;
}
}
}