aboutsummaryrefslogtreecommitdiffstats
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/cron.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/commands/cron.rs b/src/commands/cron.rs
index 301ae3d..94cf955 100644
--- a/src/commands/cron.rs
+++ b/src/commands/cron.rs
@@ -44,7 +44,12 @@ pub async fn dodaj_audio(
44 ctx.data().copyparty.build_url_no_pw(&audio_filename) 44 ctx.data().copyparty.build_url_no_pw(&audio_filename)
45 }; 45 };
46 46
47 let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; 47 if let Err(e) = crate::tasks::parse_cron(&cron_expression) {
48 ctx.say(lang::fmt_cron_invalid(&cron_expression, &e.to_string()))
49 .await?;
50 return Ok(());
51 }
52 let guild_id = ctx.guild_id().ok_or_else(|| lang::err_not_in_guild())?;
48 if !ctx.data().copyparty.is_own_url(&full_url) { 53 if !ctx.data().copyparty.is_own_url(&full_url) {
49 crate::net::ensure_public_http_url(&full_url).await?; 54 crate::net::ensure_public_http_url(&full_url).await?;
50 } 55 }
@@ -77,7 +82,12 @@ pub async fn dodaj_wiadomość(
77 _ => return Err(lang::err_bad_channel_type()), 82 _ => return Err(lang::err_bad_channel_type()),
78 }; 83 };
79 84
80 let guild_id = ctx.guild_id().ok_or_else(lang::err_not_in_guild)?; 85 if let Err(e) = crate::tasks::parse_cron(&cron_expression) {
86 ctx.say(lang::fmt_cron_invalid(&cron_expression, &e.to_string()))
87 .await?;
88 return Ok(());
89 }
90 let guild_id = ctx.guild_id().ok_or_else(|| lang::err_not_in_guild())?;
81 database::add_cron_job( 91 database::add_cron_job(
82 &ctx.data().db_pool, 92 &ctx.data().db_pool,
83 guild_id.get() as i64, 93 guild_id.get() as i64,