diff --git a/src/structures/GuildAuditLogs.js b/src/structures/GuildAuditLogs.js index f25edddc6..b9f4f6ca8 100644 --- a/src/structures/GuildAuditLogs.js +++ b/src/structures/GuildAuditLogs.js @@ -70,7 +70,7 @@ class GuildAuditLogs { */ this.entries = new Collection(); for (const item of data.audit_log_entries) { - const entry = new GuildAuditLogsEntry(guild, item); + const entry = new GuildAuditLogsEntry(this, guild, item); this.entries.set(entry.id, entry); } } @@ -183,7 +183,7 @@ class GuildAuditLogs { * Audit logs entry. */ class GuildAuditLogsEntry { - constructor(guild, data) { + constructor(logs, guild, data) { const targetType = GuildAuditLogs.targetType(data.action_type); /** * The target type of this entry @@ -281,7 +281,15 @@ class GuildAuditLogsEntry { } else if ([Targets.USER, Targets.GUILD].includes(targetType)) { this.target = guild.client[`${targetType.toLowerCase()}s`].get(data.target_id); } else if (targetType === Targets.WEBHOOK) { - this.target = this.webhooks.get(data.target_id); + this.target = logs.webhooks.get(data.target_id) || + new Webhook(guild.client, + this.changes.reduce((o, c) => { + o[c.key] = c.new || c.old; + return o; + }, { + id: data.target_id, + guild_id: guild.id, + })); } else if (targetType === Targets.INVITE) { if (guild.me.permissions.has('MANAGE_GUILD')) { const change = this.changes.find(c => c.key === 'code');