Skip to content

Commit c0f0188

Browse files
committed
fixed unmarshalling of components
1 parent 97fc1e4 commit c0f0188

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

api/message.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,18 @@ type Message struct {
193193
LastUpdated *time.Time `json:"last_updated,omitempty"`
194194
}
195195

196-
197196
// Unmarshal is used to unmarshal a Message we received from discord
198197
func (m *Message) Unmarshal(data []byte) error {
199198
var fullM struct {
199+
Components []UnmarshalComponent `json:"components,omitempty"`
200200
*Message
201-
UnmarshalComponents []UnmarshalComponent `json:"components,omitempty"`
202201
}
203202
err := json.Unmarshal(data, &fullM)
204203
if err != nil {
205204
return err
206205
}
207206
*m = *fullM.Message
208-
for _, component := range fullM.UnmarshalComponents {
207+
for _, component := range fullM.Components {
209208
m.Components = append(m.Components, createComponent(component))
210209
}
211210
return nil
@@ -218,15 +217,15 @@ func createComponent(unmarshalComponent UnmarshalComponent) Component {
218217
for i, unmarshalC := range unmarshalComponent.Components {
219218
components[i] = createComponent(unmarshalC)
220219
}
221-
return &ActionRow{
220+
return ActionRow{
222221
ComponentImpl: ComponentImpl{
223222
ComponentType: ComponentTypeActionRow,
224223
},
225224
Components: components,
226225
}
227226

228227
case ComponentTypeButton:
229-
return &Button{
228+
return Button{
230229
ComponentImpl: ComponentImpl{
231230
ComponentType: ComponentTypeButton,
232231
},

0 commit comments

Comments
 (0)