mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(GuildAuditLogs): incorrect webhook reference (#2004)
* fix(GuildAuditLogs): incorrect webhook reference * i cant trust my linter anymore * use changes object
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user