From 8fbae130408613df3c8c49a8d89b956b4ff9c1ea Mon Sep 17 00:00:00 2001 From: Isabella <11844002+Lewdcario@users.noreply.github.com> Date: Fri, 6 Oct 2017 17:55:53 -0600 Subject: [PATCH] fix(GuildAuditLogs): incorrect webhook reference (#2004) * fix(GuildAuditLogs): incorrect webhook reference * i cant trust my linter anymore * use changes object --- src/structures/GuildAuditLogs.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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');