From 077f81084bc60a2adb12a70e1e43f793d2011754 Mon Sep 17 00:00:00 2001 From: Connor King Date: Mon, 25 Mar 2024 22:06:14 -0400 Subject: [PATCH 1/2] .unwrap_or_default() instead of falling back to "" unifies prefix logic between help_single_command and help_all_commands --- src/builtins/help.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/builtins/help.rs b/src/builtins/help.rs index 8d86ae1cc401..a62eb2120f52 100644 --- a/src/builtins/help.rs +++ b/src/builtins/help.rs @@ -150,13 +150,7 @@ async fn help_single_command( subprefix = Some(format!(" /{}", command.name)); } if command.prefix_action.is_some() { - let prefix = match get_prefix_from_options(ctx).await { - Some(prefix) => prefix, - // None can happen if the prefix is dynamic, and the callback - // fails due to help being invoked with slash or context menu - // commands. Not sure there's a better way to handle this. - None => String::from(""), - }; + let prefix = match get_prefix_from_options(ctx).await.unwrap_or_default(); invocations.push(format!("`{}{}`", prefix, command.name)); if subprefix.is_none() { subprefix = Some(format!(" {}{}", prefix, command.name)); From 694f7d960791b3f986dde8c723c16307661f42bd Mon Sep 17 00:00:00 2001 From: Connor King Date: Mon, 25 Mar 2024 22:08:36 -0400 Subject: [PATCH 2/2] remove extra "match" oops --- src/builtins/help.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builtins/help.rs b/src/builtins/help.rs index a62eb2120f52..c3c483e481d5 100644 --- a/src/builtins/help.rs +++ b/src/builtins/help.rs @@ -150,7 +150,7 @@ async fn help_single_command( subprefix = Some(format!(" /{}", command.name)); } if command.prefix_action.is_some() { - let prefix = match get_prefix_from_options(ctx).await.unwrap_or_default(); + let prefix = get_prefix_from_options(ctx).await.unwrap_or_default(); invocations.push(format!("`{}{}`", prefix, command.name)); if subprefix.is_none() { subprefix = Some(format!(" {}{}", prefix, command.name));