Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ApplicationCommands to AuditLog #193

Merged
merged 2 commits into from Aug 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions discord/audit_log.go
Expand Up @@ -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"`
Expand All @@ -129,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