9
9
type ModalSubmitInteraction struct {
10
10
baseInteraction
11
11
Data ModalSubmitInteractionData `json:"data"`
12
+ // Message is only present if the modal was triggered from a button
13
+ Message * Message `json:"message,omitempty"`
12
14
}
13
15
14
16
func (i * ModalSubmitInteraction ) UnmarshalJSON (data []byte ) error {
15
17
var interaction struct {
16
18
rawInteraction
17
- Data ModalSubmitInteractionData `json:"data"`
19
+ Data ModalSubmitInteractionData `json:"data"`
20
+ Message * Message `json:"message,omitempty"`
18
21
}
19
22
if err := json .Unmarshal (data , & interaction ); err != nil {
20
23
return err
@@ -43,13 +46,19 @@ func (i *ModalSubmitInteraction) UnmarshalJSON(data []byte) error {
43
46
}
44
47
45
48
i .Data = interaction .Data
49
+ i .Message = interaction .Message
50
+ if i .Message != nil {
51
+ i .Message .GuildID = i .baseInteraction .guildID
52
+ }
46
53
return nil
47
54
}
48
55
49
56
func (i ModalSubmitInteraction ) MarshalJSON () ([]byte , error ) {
50
57
return json .Marshal (struct {
51
58
rawInteraction
52
59
Data ModalSubmitInteractionData `json:"data"`
60
+ // Message is only present if the modal was triggered from a button
61
+ Message * Message `json:"message,omitempty"`
53
62
}{
54
63
rawInteraction : rawInteraction {
55
64
ID : i .id ,
@@ -71,7 +80,8 @@ func (i ModalSubmitInteraction) MarshalJSON() ([]byte, error) {
71
80
Context : i .context ,
72
81
AttachmentSizeLimit : i .attachmentSizeLimit ,
73
82
},
74
- Data : i .Data ,
83
+ Data : i .Data ,
84
+ Message : i .Message ,
75
85
})
76
86
}
77
87
0 commit comments