[X] I have checked and am using the latest version of the library.
Current Behavior
In the ParticipantChanged event, the typing of the event don't correspond to the one being send to it.
While it's says that it will be of the type Id, it is receiving strings. Furthermore, making the need to cast the variable to unknown and then the type needed in the function, like this:
this.client.onGlobalParticipantsChanged(async change => {
if (change.action != 'add') return;
let newMembers: Id[];
if (Array.isArray(change.who))
newMembers = [...change.who];
else
newMembers = [change.who];
}
console.log(newMembers);
newMembers.forEach(userId => {
const id = userId.toString() as ContactId;
if (!id.startsWith('55')) {
client.getChatById(change.chat as unknown as `${number}@c.us`).then(chat => {
if (chat.canSend) {
client.sendText(chatId, 'Esse grupo é restrito para usuários pertencentes do Brasil');
}
});
client.removeParticipant(change.chat as unknown as GroupChatId, id)
.catch(err => logger.exception(err, 'Remove +55 from group'));
} else {
verifyBlackList(id);
}
});
});
Without casting, this error will happen:
Argument of type 'Id' is not assignable to parameter of type '`${number}@c.us`'.
WA_VERSION: 2.2132.6
PAGE_UA: 'WhatsApp/2.2108.8 Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36' │
BROWSER_VERSION 'Chrome/93.0.4577.0'
Are you using the latest version of the library?
Current Behavior
In the ParticipantChanged event, the typing of the event don't correspond to the one being send to it.
While it's says that it will be of the type Id, it is receiving strings. Furthermore, making the need to cast the variable to unknown and then the type needed in the function, like this:
Without casting, this error will happen:
Type used in typescript:
Expected Behavior
The types of ParticipantEvent be equals to the ones send to the user, and is expected that they are compatible with the clients functions
Steps To Reproduce
client.onParticipantChanged
orclient.onGlobalParticipantsChanged
Mode
My own code
create() code
DEBUG INFO
Environment
Screenshots
No response
Anything else?
No response