From a91bf1c762536055ca09a862e963ddb5e29ffe3a Mon Sep 17 00:00:00 2001 From: rafael-ofc <108157095+rafael-ofc@users.noreply.github.com> Date: Wed, 31 May 2023 09:55:45 -0300 Subject: [PATCH] Improvements in mentionedJidList and content, referring to sendMessage (#2166) * Improvements in mentions and content, referring to sendMessage * Add function in MessageMedia * fix: remove fromAll * Update src/Client.js * Update src/Client.js * Update Client.js --------- Co-authored-by: Rafael Co-authored-by: Rajeh Taher --- src/Client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Client.js b/src/Client.js index d59bac6..d5eb7b7 100644 --- a/src/Client.js +++ b/src/Client.js @@ -742,6 +742,10 @@ class Client extends EventEmitter { * @returns {Promise} Message that was just sent */ async sendMessage(chatId, content, options = {}) { + if (options.mentions && options.mentions.some(possiblyContact => possiblyContact instanceof Contact)) { + console.warn('Mentions with an array of Contact are now deprecated. See more at https://github.com/pedroslopez/whatsapp-web.js/pull/2166.'); + options.mentions = options.mentions.map(a => a.id._serialized); + } let internalOptions = { linkPreview: options.linkPreview === false ? undefined : true, sendAudioAsVoice: options.sendAudioAsVoice, @@ -751,7 +755,7 @@ class Client extends EventEmitter { caption: options.caption, quotedMessageId: options.quotedMessageId, parseVCards: options.parseVCards === false ? false : true, - mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [], + mentionedJidList: Array.isArray(options.mentions) ? options.mentions : [], extraOptions: options.extra };