Skip to content

Commit

Permalink
fix unmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
mlnrDev committed Aug 29, 2022
1 parent 608346e commit cbf61dd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions discord/audit_log.go
Expand Up @@ -130,16 +130,24 @@ type AuditLog struct {
func (l *AuditLog) UnmarshalJSON(data []byte) error {
type auditLog AuditLog
var v struct {
Integrations []UnmarshalIntegration `json:"integrations"`
Threads []UnmarshalChannel `json:"threads"`
Webhooks []UnmarshalWebhook `json:"webhooks"`
ApplicationCommands []UnmarshalApplicationCommand `json:"application_commands"`
Integrations []UnmarshalIntegration `json:"integrations"`
Threads []UnmarshalChannel `json:"threads"`
Webhooks []UnmarshalWebhook `json:"webhooks"`
auditLog
}
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*l = AuditLog(v.auditLog)

if v.ApplicationCommands != nil {
l.ApplicationCommands = make([]ApplicationCommand, len(v.ApplicationCommands))
for i := range v.ApplicationCommands {
l.ApplicationCommands[i] = v.ApplicationCommands[i].ApplicationCommand
}
}

if v.Integrations != nil {
l.Integrations = make([]Integration, len(v.Integrations))
for i := range v.Integrations {
Expand Down

0 comments on commit cbf61dd

Please sign in to comment.