feat: Global Display Name

This commit is contained in:
Elysia 2023-05-18 15:44:38 +07:00
parent 4f3aebf9c6
commit 8a19880820
2 changed files with 25 additions and 6 deletions

View File

@ -87,13 +87,22 @@ class ClientUser extends User {
if ('bio' in data) { if ('bio' in data) {
this.bio = data.bio; this.bio = data.bio;
} }
if ('global_name' in data) {
/**
* Display name of the client user.
* @type {?string}
*/
this.displayName = data.global_name;
}
if (!this.friendNicknames?.size) {
/** /**
* The friend nicknames cache of the client user. * The friend nicknames cache of the client user.
* @type {Collection<Snowflake, string>} * @type {Collection<Snowflake, string>}
* @private * @private
*/ */
if (!this.friendNicknames?.size) this.friendNicknames = new Collection(); this.friendNicknames = new Collection();
}
if (!this._intervalSamsungPresence) { if (!this._intervalSamsungPresence) {
this._intervalSamsungPresence = setInterval(() => { this._intervalSamsungPresence = setInterval(() => {
@ -601,6 +610,15 @@ class ClientUser extends User {
fetchBurstCredit() { fetchBurstCredit() {
return this.client.api.users['@me']['burst-credits'].get().then(d => d.amount); 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<ClientUser>}
*/
setDisplayName(displayName = '') {
return this.edit({ global_name: displayName });
}
} }
module.exports = ClientUser; module.exports = ClientUser;

1
typings/index.d.ts vendored
View File

@ -1085,6 +1085,7 @@ export class ClientUser extends User {
public readonly nsfwAllowed: boolean; public readonly nsfwAllowed: boolean;
public readonly emailAddress: string; public readonly emailAddress: string;
public stopRinging(channel: ChannelResolvable): Promise<void>; public stopRinging(channel: ChannelResolvable): Promise<void>;
public setDisplayName(displayName?: string): Promise<this>;
} }
type NitroType = 'NONE' | 'NITRO_CLASSIC' | 'NITRO_BOOST' | 'NITRO_BASIC'; type NitroType = 'NONE' | 'NITRO_CLASSIC' | 'NITRO_BOOST' | 'NITRO_BASIC';