From aa749efa643547c64001890645962c6fd8837261 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:57:21 +0700 Subject: [PATCH] fix #721 --- src/structures/ClientUser.js | 2 +- src/structures/User.js | 26 +++++++++++++++++--------- typings/index.d.ts | 10 ++++++---- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index a1a41b5..32f6c29 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -617,7 +617,7 @@ class ClientUser extends User { /** * Set pronouns - * @param {string | null} pronouns + * @param {?string} pronouns Your pronouns * @returns {Promise} */ setPronouns(pronouns = '') { diff --git a/src/structures/User.js b/src/structures/User.js index c570104..a220c86 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -54,33 +54,29 @@ class User extends Base { * Time that User has nitro (Unix Timestamp) * The user must be force fetched for this property to be present or be updated * @type {?number} - * @readonly */ this.premiumSince = null; /** * Time that User has nitro and boost server (Unix Timestamp) * @type {?number} - * @readonly */ this.premiumGuildSince = null; /** * About me (User) * The user must be force fetched for this property to be present or be updated * @type {?string} - * @readonly */ this.bio = null; /** - * This user is on the same servers as Client User + * Pronouns (User) * The user must be force fetched for this property to be present or be updated - * @type {Collection} - * @readonly + * @type {?string} */ - this.mutualGuilds = new Collection(); + this.pronouns = null; + this._mutualGuilds = []; /** * [Bot] Application * @type {?ClientApplication} - * @readonly */ this.application = application ? new ClientApplication(this.client, application, this) : null; this._partial = true; @@ -202,6 +198,16 @@ class User extends Base { } } + /** + * This user is on the same servers as Client User + * The user must be force fetched for this property to be present or be updated + * @type {Collection} + * @readonly + */ + get mutualGuilds() { + return new Collection(this._mutualGuilds.map(obj => [obj.id, obj])); + } + /** * Get all mutual friends (Client -> User) * @type {Promise>} @@ -335,7 +341,9 @@ class User extends Base { // Unknown } - this.mutualGuilds = new Collection(data.mutual_guilds.map(obj => [obj.id, obj])); + if ('mutual_guilds' in data) { + this._mutualGuilds = data.mutual_guilds; + } } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 1e8447c..308be12 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1090,6 +1090,7 @@ export class ClientUser extends User { public readonly emailAddress: string; public stopRinging(channel: ChannelResolvable): Promise; public setGlobalName(globalName?: string): Promise; + public setPronouns(pronouns?: string): Promise; } type NitroType = 'NONE' | 'NITRO_CLASSIC' | 'NITRO_BOOST' | 'NITRO_BASIC'; @@ -3256,6 +3257,7 @@ export class User extends PartialTextBasedChannel(Base) { public avatarDecoration: string | null; public banner: string | null | undefined; public bot: boolean; + public pronouns: string | null; public readonly createdAt: Date; public readonly relationships: RelationshipTypes; public readonly createdTimestamp: number; @@ -3275,10 +3277,10 @@ export class User extends PartialTextBasedChannel(Base) { public username: string; public readonly note: string | null; public readonly nickname: string | null; - public readonly connectedAccounts: object[]; - public readonly premiumSince: Date; - public readonly premiumGuildSince: Date; - public readonly bio: string | null; + public connectedAccounts: object[]; + public premiumSince: Date; + public premiumGuildSince: Date; + public bio: string | null; public readonly mutualGuilds: Collection; public readonly mutualFriends: Promise>; public readonly voice: VoiceState;