From 16bdcd40d2150210cbc78c80c3b638b87be5e8a1 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Thu, 8 Apr 2021 17:25:10 +0200 Subject: [PATCH] fix(GuildAuditLogsEntry): executor can be missing --- src/structures/GuildAuditLogs.js | 10 ++++++---- typings/index.d.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/structures/GuildAuditLogs.js b/src/structures/GuildAuditLogs.js index aab133d4cc3a..81a3d0d78e6e 100644 --- a/src/structures/GuildAuditLogs.js +++ b/src/structures/GuildAuditLogs.js @@ -319,11 +319,13 @@ class GuildAuditLogsEntry { /** * The user that executed this entry - * @type {User} + * @type {?User} */ - this.executor = guild.client.options.partials.includes(PartialTypes.USER) - ? guild.client.users.add({ id: data.user_id }) - : guild.client.users.cache.get(data.user_id); + 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) + : null; /** * An entry in the audit log representing a specific change. diff --git a/typings/index.d.ts b/typings/index.d.ts index ea41f7e95631..75dabba94ee3 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -727,7 +727,7 @@ declare module 'discord.js' { public changes: AuditLogChange[] | null; public readonly createdAt: Date; public readonly createdTimestamp: number; - public executor: User; + public executor: User | null; public extra: object | Role | GuildMember | null; public id: Snowflake; public reason: string | null;