From 9da553ecb9313ca80994ed19f9bcd3e64e23a413 Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Mon, 17 Aug 2020 22:19:29 -0400 Subject: [PATCH] feat: Set client's display name (pushname) --- index.d.ts | 6 ++++++ src/Client.js | 11 +++++++++++ 2 files changed, 17 insertions(+) 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}