@@ -225,7 +225,7 @@ class GuildAuditLogs {
|
||||
*/
|
||||
this.entries = new Collection();
|
||||
for (const item of data.audit_log_entries) {
|
||||
const entry = new GuildAuditLogsEntry(this, guild, item);
|
||||
const entry = new GuildAuditLogsEntry(guild, item, this);
|
||||
this.entries.set(entry.id, entry);
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ class GuildAuditLogs {
|
||||
* Audit logs entry.
|
||||
*/
|
||||
class GuildAuditLogsEntry {
|
||||
constructor(logs, guild, data) {
|
||||
constructor(guild, data, logs) {
|
||||
const targetType = GuildAuditLogs.targetType(data.action_type);
|
||||
/**
|
||||
* The target type of this entry
|
||||
@@ -410,6 +410,12 @@ class GuildAuditLogsEntry {
|
||||
*/
|
||||
this.reason = data.reason ?? null;
|
||||
|
||||
/**
|
||||
* The id of the user that executed this entry
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.executorId = data.user_id;
|
||||
|
||||
/**
|
||||
* The user that executed this entry
|
||||
* @type {?User}
|
||||
@@ -417,7 +423,7 @@ class GuildAuditLogsEntry {
|
||||
this.executor = data.user_id
|
||||
? guild.client.options.partials.includes(PartialTypes.USER)
|
||||
? guild.client.users._add({ id: data.user_id })
|
||||
: guild.client.users.cache.get(data.user_id)
|
||||
: guild.client.users.cache.get(data.user_id) ?? null
|
||||
: null;
|
||||
|
||||
/**
|
||||
@@ -521,6 +527,12 @@ class GuildAuditLogsEntry {
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the target of this entry
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.targetId = data.target_id;
|
||||
|
||||
/**
|
||||
* The target of this entry
|
||||
* @type {?AuditLogEntryTarget}
|
||||
@@ -536,12 +548,12 @@ class GuildAuditLogsEntry {
|
||||
} else if (targetType === Targets.USER && data.target_id) {
|
||||
this.target = guild.client.options.partials.includes(PartialTypes.USER)
|
||||
? guild.client.users._add({ id: data.target_id })
|
||||
: guild.client.users.cache.get(data.target_id);
|
||||
: guild.client.users.cache.get(data.target_id) ?? null;
|
||||
} else if (targetType === Targets.GUILD) {
|
||||
this.target = guild.client.guilds.cache.get(data.target_id);
|
||||
} else if (targetType === Targets.WEBHOOK) {
|
||||
this.target =
|
||||
logs.webhooks.get(data.target_id) ??
|
||||
logs?.webhooks.get(data.target_id) ??
|
||||
new Webhook(
|
||||
guild.client,
|
||||
this.changes.reduce(
|
||||
@@ -576,10 +588,10 @@ class GuildAuditLogsEntry {
|
||||
this.target =
|
||||
data.action_type === Actions.MESSAGE_BULK_DELETE
|
||||
? guild.channels.cache.get(data.target_id) ?? { id: data.target_id }
|
||||
: guild.client.users.cache.get(data.target_id);
|
||||
: guild.client.users.cache.get(data.target_id) ?? null;
|
||||
} else if (targetType === Targets.INTEGRATION) {
|
||||
this.target =
|
||||
logs.integrations.get(data.target_id) ??
|
||||
logs?.integrations.get(data.target_id) ??
|
||||
new Integration(
|
||||
guild.client,
|
||||
this.changes.reduce(
|
||||
|
Reference in New Issue
Block a user