aboutsummaryrefslogtreecommitdiffstats
path: root/src/commands/cron.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/commands/cron.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/commands/cron.rs b/src/commands/cron.rs
index 48f6ff1..a645581 100644
--- a/src/commands/cron.rs
+++ b/src/commands/cron.rs
@@ -32,12 +32,22 @@ pub async fn dodaj_audio(
32 _ => return Err(lang::err_bad_channel_type()), 32 _ => return Err(lang::err_bad_channel_type()),
33 }; 33 };
34 34
35 // Resolve full path from autocomplete cache (value is truncated to 99 chars by Discord)
36 let full_url = if let Some(hit) = ctx.data().ac_lookup(ctx.author().id, &audio_filename).await {
37 let path = hit.url_path().unwrap_or(&audio_filename);
38 ctx.data().copyparty.build_url_no_pw(path)
39 } else if audio_filename.starts_with("http://") || audio_filename.starts_with("https://") {
40 audio_filename.clone()
41 } else {
42 ctx.data().copyparty.build_url_no_pw(&audio_filename)
43 };
44
35 database::add_cron_job( 45 database::add_cron_job(
36 &ctx.data().db_pool, 46 &ctx.data().db_pool,
37 &cron_expression, 47 &cron_expression,
38 "audio", 48 "audio",
39 channel_id, 49 channel_id,
40 Some(&audio_filename), 50 Some(&full_url),
41 None, 51 None,
42 ) 52 )
43 .await?; 53 .await?;