whatsapp-web.js
whatsapp-web.js copied to clipboard
chat.clearMessages only work for signedInUser but not for all participants
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I still have the same problem, can't clearMessages even though return true
class WhatsAppClient extends Client {
myGroupName = 'Locum Finder'
constructor() {
super({
puppeteer: {
args: ["--no-sandbox"]
},
authStrategy: new LocalAuth({
clientId: 'whatsapp',
dataPath: './'
})
})
this.phoneNum = null
this.myPhoneNum = null;
this.groupID = null;
this.qrImage = callbackPromise()
this.attachListeners()
}
async getPhoneNumId(phoneNum) {
phoneNum = phoneNum.replace(/[^\d]/g, "")
let { _serialized } = await super.getNumberId(phoneNum)
return _serialized;
}
async attachListeners() {
// WhatsApp ready
this.on(Events.READY, async () => {
log.success('whatsapp ready');
this.myPhoneNum = await this.getPhoneNumId(phone)
this.otherPhoneNum = await this.getPhoneNumId(SecParty_phone_num)
return super.getChats().then((chats) => {
const myGroup = chats.find((chat) => chat.name === this.myGroupName);
if (process.env.NODE_ENV == 'dev') {
myGroup.clearMessages().then(status => {
console.log(status) ----->> !! HERE! this line showed true, but nothing cleared!!
})
}
if (!myGroup) {
return super.createGroup(this.myGroupName, [this.myPhoneNum]).then((createGroup) => {
log.success(`group ${this.myGroupName} created!`)
this.groupID = createGroup.gid._serialized
})
} else {
this.groupID = myGroup.id._serialized
}
Expected behavior
Supposed to clear everychat in group
Steps to Reproduce the Bug or Issue
Just use my code above. I've tried getChatByID still the same not cleared :(
Relevant Code
No response
Browser Type
Other (please write in Additional Context)
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
windows
Additional context
No response
I found out it did clear chats only for owner of group, how do i clear for all participants as well?
await message.delete(); // Excluir a mensagem recebida.
Inclua isso ao comando "limpartudo" que esse comando irá apagar as mensagens recebidas.
Clear is only for you. You can run on every messages in the chat and revoke them for everyone