mirror of
https://github.com/Xevion/r2park.git
synced 2025-12-09 16:08:12 -06:00
Map modal submission by identifier, acquire & print email
This commit is contained in:
30
submit.go
30
submit.go
@@ -2,13 +2,15 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/samber/lo"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func RegisterModalHandler(session *discordgo.Session, interaction *discordgo.InteractionCreate) {
|
||||
// TODO: Pull in all parameters from the form
|
||||
// TOOD: Pull in all hidden parameters form database
|
||||
// TODO: Pull in resident ID from database
|
||||
|
||||
err := session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
@@ -19,10 +21,34 @@ func RegisterModalHandler(session *discordgo.Session, interaction *discordgo.Int
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
data := interaction.ModalSubmitData()
|
||||
spew.Dump(data)
|
||||
dataByCustomID := lo.SliceToMap(data.Components, func(c discordgo.MessageComponent) (string, discordgo.MessageComponent) {
|
||||
inner := c.(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput)
|
||||
return inner.CustomID, inner
|
||||
})
|
||||
|
||||
email := dataByCustomID["email"].(*discordgo.TextInput).Value
|
||||
log.Infof("Email: %s", email)
|
||||
|
||||
// TOOD: Submit registration request to API
|
||||
// TODO: Edit response to indicate success/failure
|
||||
// TOOD: On success, provide a button to submit email confirmation
|
||||
|
||||
// TODO: Validate license plate
|
||||
// session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
|
||||
// Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
// Data: &discordgo.InteractionResponseData{
|
||||
// Embeds: []*discordgo.MessageEmbed{
|
||||
// {
|
||||
// Footer: &discordgo.MessageEmbedFooter{
|
||||
// Text: GetFooterText(),
|
||||
// },
|
||||
// Description: "testing 123",
|
||||
// Fields: []*discordgo.MessageEmbedField{},
|
||||
// },
|
||||
// },
|
||||
// AllowedMentions: &discordgo.MessageAllowedMentions{},
|
||||
// },
|
||||
// })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user