mirror of
https://github.com/Xevion/r2park.git
synced 2025-12-06 01:15:57 -06:00
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package main
|
|
|
|
import "github.com/bwmarrin/discordgo"
|
|
|
|
// FormToComponents converts the form requested into usable modal components.
|
|
func FormToComponents(form GetFormResult) []discordgo.MessageComponent {
|
|
components := make([]discordgo.MessageComponent, 0, 3)
|
|
|
|
for _, field := range form.fields {
|
|
var component discordgo.TextInput
|
|
|
|
switch field.id {
|
|
case "vehicleApt":
|
|
component = discordgo.TextInput{
|
|
CustomID: "vehicleApt",
|
|
Label: "Apartment Number",
|
|
Style: discordgo.TextInputShort,
|
|
Required: true,
|
|
MinLength: 1,
|
|
MaxLength: 5,
|
|
}
|
|
case "vehicleMake":
|
|
component = discordgo.TextInput{
|
|
CustomID: "vehicleMake",
|
|
Label: "Make",
|
|
Placeholder: "Honda",
|
|
Style: discordgo.TextInputShort,
|
|
Required: true,
|
|
MinLength: 4,
|
|
MaxLength: 15,
|
|
}
|
|
case "vehicleModel":
|
|
component = discordgo.TextInput{
|
|
CustomID: "vehicleModel",
|
|
Label: "Model",
|
|
Style: discordgo.TextInputShort,
|
|
Placeholder: "Accord",
|
|
Required: true,
|
|
MinLength: 1,
|
|
MaxLength: 16,
|
|
}
|
|
case "vehicleLicensePlate":
|
|
component = discordgo.TextInput{
|
|
CustomID: "vehicleLicensePlate",
|
|
Label: "License Plate",
|
|
Placeholder: "ABC123",
|
|
Style: discordgo.TextInputShort,
|
|
Required: true,
|
|
MinLength: 1,
|
|
MaxLength: 9,
|
|
}
|
|
|
|
components = append(components, discordgo.ActionsRow{
|
|
Components: []discordgo.MessageComponent{
|
|
component,
|
|
},
|
|
})
|
|
}
|
|
}
|
|
|
|
return components
|
|
}
|