From 8d9458ff4927376e3d1f1bbdd86a760f327c05ec Mon Sep 17 00:00:00 2001 From: jellywx Date: Thu, 17 Jun 2021 13:23:08 +0100 Subject: [PATCH] delete command fix --- src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2872ce1..83ebfe4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1219,6 +1219,12 @@ async fn change_public( #[command("delete")] #[description("Delete a sound you have uploaded")] +#[arg( + name = "query", + description = "Delete sound with the specified name or ID", + kind = "String", + required = true +)] async fn delete_sound( ctx: &Context, invoke: &(dyn CommandInvoke + Sync + Send), @@ -1235,9 +1241,12 @@ async fn delete_sound( let uid = invoke.author_id().0; let gid = invoke.guild_id().unwrap().0; - let name = args.named("query").unwrap(); + let name = args + .named("query") + .map(|s| s.to_owned()) + .unwrap_or(String::new()); - let sound_vec = Sound::search_for_sound(name, gid, uid, pool.clone(), true).await?; + let sound_vec = Sound::search_for_sound(&name, gid, uid, pool.clone(), true).await?; let sound_result = sound_vec.first(); match sound_result {