bwmarrin / discordgo

(Golang) Go bindings for Discord
BSD 3-Clause "New" or "Revised" License
5.11k stars 813 forks source link

Modal Submission not sending field data #1507

Closed taiidani closed 8 months ago

taiidani commented 8 months ago

Hello, I'm having issues propagating field data from a modal into the InteractionModalSubmit event. For some reason, only the custom_id is being passed through, with none of the data from the TextInputs that I included in the modal.

My modal code:

&discordgo.InteractionResponse{
    Type: discordgo.InteractionResponseModal,
    Data: &discordgo.InteractionResponseData{
        CustomID: "time-txt",
        Title:    "Change Time",
        Components: []discordgo.MessageComponent{
            discordgo.ActionsRow{
                Components: []discordgo.MessageComponent{
                    discordgo.TextInput{
                        CustomID:    "txt-date",
                        Style:       discordgo.TextInputShort,
                        Required:    true,
                        Label:       "Date",
                        Value:       opts.Date,
                        Placeholder: "YYYYMMDD",
                        MinLength:   8,
                        MaxLength:   10,
                    },
                },
            },
            discordgo.ActionsRow{
                Components: []discordgo.MessageComponent{
                    discordgo.TextInput{
                        CustomID:    "txt-time",
                        Style:       discordgo.TextInputShort,
                        Required:    true,
                        Label:       "Time",
                        Value:       opts.Time,
                        Placeholder: "HH:MM:SS",
                        MinLength:   5,
                        MaxLength:   8,
                    },
                },
            },
        },
    },
}

And the part of the JSON-encoded InteractionModalSubmit message where I would have expected the components to be included in the response:

{
    "id": "1216086183621427310",
    "application_id": "927342248117538816",
    "type": 5,
    "data": {
        "custom_id": "time-txt"
    },

    ...
}

Shouldn't this include a components field containing the components that were submitted? Or am I looking in the wrong place?

taiidani commented 8 months ago

Ah, it appears as though components is just excluded from all JSON encoding. Actually trying to retrieve the components from the Components array shows that they are in fact there!