added length check to timer creation
This commit is contained in:
parent
632d01f503
commit
bfc48a986d
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1316,7 +1316,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "reminder_rs"
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"async-trait",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "reminder_rs"
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
authors = ["jellywx <judesouthworth@pm.me>"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user