Skip to content

Commit

Permalink
revert audit log changes
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Sep 7, 2022
1 parent 35e4cf6 commit d3e127e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion discord/audit_log.go
Expand Up @@ -117,8 +117,8 @@ const (

// AuditLog (https://discord.com/developers/docs/resources/audit-log) These are logs of events that occurred, accessible via the Discord
type AuditLog struct {
Entries []AuditLogEntry `json:"audit_log_entries"`
ApplicationCommands []ApplicationCommand `json:"application_commands"`
AuditLogEntries []AuditLogEntry `json:"audit_log_entries"`
AutoModerationRules []AutoModerationRule `json:"auto_moderation_rules"`
GuildScheduledEvents []GuildScheduledEvent `json:"guild_scheduled_events"`
Integrations []Integration `json:"integrations"`
Expand All @@ -132,6 +132,7 @@ func (l *AuditLog) UnmarshalJSON(data []byte) error {
var v struct {
ApplicationCommands []UnmarshalApplicationCommand `json:"application_commands"`
Integrations []UnmarshalIntegration `json:"integrations"`
Threads []UnmarshalChannel `json:"threads"`
Webhooks []UnmarshalWebhook `json:"webhooks"`
auditLog
}
Expand All @@ -154,6 +155,13 @@ func (l *AuditLog) UnmarshalJSON(data []byte) error {
}
}

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

if v.Webhooks != nil {
l.Webhooks = make([]Webhook, len(v.Webhooks))
for i := range v.Webhooks {
Expand Down
6 changes: 3 additions & 3 deletions rest/page.go
Expand Up @@ -65,12 +65,12 @@ func (p *AuditLogPage) Previous() bool {
return false
}

if len(p.Entries) > 0 {
p.ID = p.Entries[len(p.Entries)-1].ID
if len(p.AuditLogEntries) > 0 {
p.ID = p.AuditLogEntries[len(p.AuditLogEntries)-1].ID
}

p.AuditLog, p.Err = p.getItems(p.ID)
if p.Err == nil && len(p.Entries) == 0 {
if p.Err == nil && len(p.AuditLogEntries) == 0 {
p.Err = ErrNoMorePages
}
return p.Err == nil
Expand Down

0 comments on commit d3e127e

Please sign in to comment.