From 608346e4756c2b8643627452474b5e2324d2afd6 Mon Sep 17 00:00:00 2001 From: caneleex Date: Tue, 16 Aug 2022 18:07:18 +0200 Subject: [PATCH 1/2] add ApplicationCommands to AuditLog --- discord/audit_log.go | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/audit_log.go b/discord/audit_log.go index 9ee3c50d..17ddadc9 100644 --- a/discord/audit_log.go +++ b/discord/audit_log.go @@ -117,6 +117,7 @@ const ( // AuditLog (https://discord.com/developers/docs/resources/audit-log) These are logs of events that occurred, accessible via the Discord type AuditLog struct { + ApplicationCommands []ApplicationCommand `json:"application_commands"` AuditLogEntries []AuditLogEntry `json:"audit_log_entries"` AutoModerationRules []AutoModerationRule `json:"auto_moderation_rules"` GuildScheduledEvents []GuildScheduledEvent `json:"guild_scheduled_events"` From cbf61dd31840a5de64550be5797491b4677ea96f Mon Sep 17 00:00:00 2001 From: caneleex Date: Mon, 29 Aug 2022 21:16:21 +0200 Subject: [PATCH 2/2] fix unmarshalling --- discord/audit_log.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/discord/audit_log.go b/discord/audit_log.go index 17ddadc9..a1909637 100644 --- a/discord/audit_log.go +++ b/discord/audit_log.go @@ -130,9 +130,10 @@ 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 { @@ -140,6 +141,13 @@ func (l *AuditLog) UnmarshalJSON(data []byte) error { } *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 {