diff --git a/index.d.ts b/index.d.ts index e855cc4..4698c0c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -84,6 +84,12 @@ declare namespace WAWebJS { */ setStatus(status: string): Promise + /** + * Sets the current user's display name + * @param displayName New display name + */ + setDisplayName(displayName: string): Promise + /** Changes and returns the archive state of the Chat */ unarchiveChat(chatId: string): Promise diff --git a/src/Client.js b/src/Client.js index 0acd447..4ba1f57 100644 --- a/src/Client.js +++ b/src/Client.js @@ -556,6 +556,17 @@ class Client extends EventEmitter { }, status); } + /** + * Sets the current user's display name. + * This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile. + * @param {string} displayName New display name + */ + async setDisplayName(displayName) { + await this.pupPage.evaluate(async displayName => { + return await window.Store.Wap.setPushname(displayName); + }, displayName); + } + /** * Gets the current connection state for the client * @returns {WAState}