fix(GuildAuditLogsEntry): executor can be missing (#5500)

This commit is contained in:
Souji
2021-04-15 00:37:45 +02:00
committed by GitHub
parent fe93a7e084
commit e9bf206d88
2 changed files with 7 additions and 5 deletions

View File

@@ -319,11 +319,13 @@ class GuildAuditLogsEntry {
/** /**
* The user that executed this entry * The user that executed this entry
* @type {User} * @type {?User}
*/ */
this.executor = guild.client.options.partials.includes(PartialTypes.USER) this.executor = data.user_id
? guild.client.users.add({ id: data.user_id }) ? guild.client.options.partials.includes(PartialTypes.USER)
: guild.client.users.cache.get(data.user_id); ? guild.client.users.add({ id: data.user_id })
: guild.client.users.cache.get(data.user_id)
: null;
/** /**
* An entry in the audit log representing a specific change. * An entry in the audit log representing a specific change.

2
typings/index.d.ts vendored
View File

@@ -744,7 +744,7 @@ declare module 'discord.js' {
public changes: AuditLogChange[] | null; public changes: AuditLogChange[] | null;
public readonly createdAt: Date; public readonly createdAt: Date;
public readonly createdTimestamp: number; public readonly createdTimestamp: number;
public executor: User; public executor: User | null;
public extra: object | Role | GuildMember | null; public extra: object | Role | GuildMember | null;
public id: Snowflake; public id: Snowflake;
public reason: string | null; public reason: string | null;