From a18c5469b0bdf430060309359b58e2f63abdc593 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 8 Jul 2026 14:24:55 +0200 Subject: remember links during audio file completion Signed-off-by: salmonik --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/autocomplete.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9532efb..0d39213 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4391,7 +4391,7 @@ dependencies = [ [[package]] name = "senator-sperma" -version = "0.2.1" +version = "0.2.2" dependencies = [ "chrono", "cron", diff --git a/Cargo.toml b/Cargo.toml index 3a56fe2..31b0ea1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "senator-sperma" -version = "0.2.1" +version = "0.2.2" edition = "2024" [profile.dev] diff --git a/src/commands/autocomplete.rs b/src/commands/autocomplete.rs index 497aec9..422ab2d 100644 --- a/src/commands/autocomplete.rs +++ b/src/commands/autocomplete.rs @@ -49,10 +49,12 @@ pub async fn audio_file<'a>( let Some(label) = filename_label(&rp) else { continue; }; - ctx.data() - .ac_stash(ctx.author().id, label.clone(), hit) - .await; - eprintln!("[DEBUG] -> cached as {label:?}"); + // Stash under the choice VALUE (`rp`), not the display label: + // the command receives `rp` as its argument and looks the hit + // up by that same key, so the cached link is reused instead of + // triggering a fresh copyparty search. + ctx.data().ac_stash(ctx.author().id, rp.clone(), hit).await; + eprintln!("[DEBUG] -> cached as {rp:?}"); choices.push(serenity::AutocompleteChoice::new(label.clone(), rp)); if choices.len() >= 25 { break; -- cgit v1.2.3