Fix FormToComponents only adding licnese plates, add default for unexpected component

This commit is contained in:
2023-12-17 06:11:06 -06:00
parent c47e8ea2e3
commit 71032b22fe

20
form.go
View File

@@ -1,6 +1,9 @@
package main
import "github.com/bwmarrin/discordgo"
import (
"github.com/bwmarrin/discordgo"
log "github.com/sirupsen/logrus"
)
// FormToComponents converts the form requested into usable modal components.
func FormToComponents(form GetFormResult) []discordgo.MessageComponent {
@@ -49,13 +52,16 @@ func FormToComponents(form GetFormResult) []discordgo.MessageComponent {
MinLength: 1,
MaxLength: 9,
}
components = append(components, discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
component,
},
})
default:
log.Warnf("unexpected field handled for \"%s\" (%v, %s)", form.propertyName, field.id, field.text)
}
// Each field is contained within its own row.
components = append(components, discordgo.ActionsRow{
Components: []discordgo.MessageComponent{
component,
},
})
}
return components