From d8b9f815c075ce5853c264c6f36d8ea5913666b2 Mon Sep 17 00:00:00 2001 From: Fdvkey Date: Thu, 16 Jul 2026 10:47:37 +0700 Subject: [PATCH] fix: replace hardcoded prefix cache with dynamic parameter mapping --- cmds/general/help.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmds/general/help.go b/cmds/general/help.go index 3e66aa1..4574b0f 100644 --- a/cmds/general/help.go +++ b/cmds/general/help.go @@ -19,8 +19,8 @@ var ( menuOnce sync.Once ) -// buildMenuCache generates the static portion of the help menu -func buildMenuCache(prefix string) { +// buildMenuCache generates the static portion of the help menu with a {{PREFIX}} placeholder +func buildMenuCache() { var sb strings.Builder cmdMap := make(map[string][]string) @@ -39,7 +39,7 @@ func buildMenuCache(prefix string) { if i == len(cmds)-1 { branch = "ā””" } - sb.WriteString(fmt.Sprintf("%s %s%s\n", branch, prefix, cmdName)) + sb.WriteString(fmt.Sprintf("%s {{PREFIX}}%s\n", branch, cmdName)) } } @@ -82,11 +82,14 @@ var Help = &core.Command{ // Calculate the static command layout part only once menuOnce.Do(func() { - buildMenuCache(prefix) + buildMenuCache() }) + // Replace placeholder with the dynamically used prefix + finalMenu := strings.ReplaceAll(cachedMenu, "{{PREFIX}}", prefix) + header := fmt.Sprintf("%s *%s*šŸ‘‹\nšŸ“¬ Need help? Here are all of my commands\n", greeting, pushName) - ctx.Reply(header + cachedMenu) + ctx.Reply(header + finalMenu) }, }