From 8a19880820e714652a30911cb43debb427095dd4 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Thu, 18 May 2023 15:44:38 +0700 Subject: [PATCH] feat: Global Display Name --- src/structures/ClientUser.js | 30 ++++++++++++++++++++++++------ typings/index.d.ts | 1 + 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index e00be1c..620f76d 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -87,13 +87,22 @@ class ClientUser extends User { if ('bio' in data) { this.bio = data.bio; } + if ('global_name' in data) { + /** + * Display name of the client user. + * @type {?string} + */ + this.displayName = data.global_name; + } - /** - * The friend nicknames cache of the client user. - * @type {Collection} - * @private - */ - if (!this.friendNicknames?.size) this.friendNicknames = new Collection(); + if (!this.friendNicknames?.size) { + /** + * The friend nicknames cache of the client user. + * @type {Collection} + * @private + */ + this.friendNicknames = new Collection(); + } if (!this._intervalSamsungPresence) { this._intervalSamsungPresence = setInterval(() => { @@ -601,6 +610,15 @@ class ClientUser extends User { fetchBurstCredit() { return this.client.api.users['@me']['burst-credits'].get().then(d => d.amount); } + + /** + * Set display name + * @param {string} displayName The new display name + * @returns {Promise} + */ + setDisplayName(displayName = '') { + return this.edit({ global_name: displayName }); + } } module.exports = ClientUser; diff --git a/typings/index.d.ts b/typings/index.d.ts index 79f1634..8c3cfc0 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1085,6 +1085,7 @@ export class ClientUser extends User { public readonly nsfwAllowed: boolean; public readonly emailAddress: string; public stopRinging(channel: ChannelResolvable): Promise; + public setDisplayName(displayName?: string): Promise; } type NitroType = 'NONE' | 'NITRO_CLASSIC' | 'NITRO_BOOST' | 'NITRO_BASIC';