From e44ae961005358dac7032c75bfc74be3b719e5a1 Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Sun, 27 Jun 2021 12:46:24 +0100 Subject: [PATCH] fix(User): fix bot and system properties being incorrect in some cases (#5923) --- src/structures/User.js | 11 +++++++++-- typings/index.d.ts | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/structures/User.js b/src/structures/User.js index 1deb996916aa..351c31918559 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -27,7 +27,10 @@ class User extends Base { */ this.id = data.id; + this.bot = null; + this.system = null; + this.flags = null; /** @@ -56,12 +59,14 @@ class User extends Base { this.username = null; } - if ('bot' in data || typeof this.bot !== 'boolean') { + if ('bot' in data) { /** * Whether or not the user is a bot - * @type {boolean} + * @type {?boolean} */ this.bot = Boolean(data.bot); + } else if (!this.partial && typeof this.bot !== 'boolean') { + this.bot = false; } if ('discriminator' in data) { @@ -90,6 +95,8 @@ class User extends Base { * @type {?boolean} */ this.system = Boolean(data.system); + } else if (!this.partial && typeof this.system !== 'boolean') { + this.system = false; } if ('public_flags' in data) { diff --git a/typings/index.d.ts b/typings/index.d.ts index 125bbf5e3431..b08ffd7bbd77 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1977,7 +1977,7 @@ declare module 'discord.js' { public lastMessageID: Snowflake | null; public readonly partial: false; public readonly presence: Presence; - public system: boolean | null; + public system: boolean; public readonly tag: string; public username: string; public avatarURL(options?: ImageURLOptions): string | null; @@ -4024,9 +4024,9 @@ declare module 'discord.js' { type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION'; interface PartialUser extends Omit, 'deleted'> { - bot: User['bot']; + bot: null; flags: User['flags']; - system: User['system']; + system: null; readonly tag: null; username: null; }