From b287a95c31388c8f6ce982d6e949cd9072691912 Mon Sep 17 00:00:00 2001 From: William Perron Date: Sun, 24 Dec 2023 12:26:49 -0500 Subject: [PATCH] fix bug in logging middleware --- cmd/themis-server/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 9e004fb..178d5f2 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -897,7 +897,23 @@ func logCommandInvocation(name string, s *discordgo.Session, i *discordgo.Intera Str("params", func() string { p := make([]string, 0, len(i.ApplicationCommandData().Options)) for _, o := range i.ApplicationCommandData().Options { - p = append(p, o.Name+"="+o.StringValue()) + sb := strings.Builder{} + sb.WriteString(o.Name) + sb.WriteRune('=') + + switch o.Type { + case discordgo.ApplicationCommandOptionSubCommand, discordgo.ApplicationCommandOptionSubCommandGroup: + panic("unreachable") + case discordgo.ApplicationCommandOptionString: + sb.WriteString(o.StringValue()) + case discordgo.ApplicationCommandOptionInteger: + sb.WriteString(fmt.Sprint(o.IntValue())) + case discordgo.ApplicationCommandOptionBoolean: + sb.WriteString(fmt.Sprint(o.BoolValue())) + default: + sb.WriteString("[unsupported type]") + } + p = append(p, sb.String()) } return strings.Join(p, ", ") }()).