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 <you@example.com>
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
This commit is contained in:
rafael-ofc 2023-05-31 09:55:45 -03:00 • committed by GitHub
commit a91bf1c762
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -742,6 +742,10 @@ class Client extends EventEmitter {
* @returns {Promise<Message>} 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
};