fix bug in logging middleware

new-sql-view
William Perron 11 months ago
parent 07252229e0
commit b287a95c31
Signed by: wperron
GPG Key ID: BFDB4EF72D73C5F2

@ -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, ", ")
}()).

Loading…
Cancel
Save