Using the code below, only the "sendText" is sent.
When it arrives at "sendImage" the system stops and does not return any message and does not continue the loop.
can you help me?
const venom = require('venom-bot');
venom
.create({
session: 'campanha', //name of session
multidevice: true // for version not multidevice use false.(default: true)
})
.then((client) => start(client))
.catch((erro) => {
console.log(erro);
});
async function start(client) {
let grupos = await getGroups(client)
let filterGrupos = grupos.filter(group => {
return group.name.trim() !== 'Wave x Unick' && group.name.trim() !== 'LTPC - Wave' && group.name.trim() !== 'Projetos Wave' &&
group.name.trim() !== 'Clicou Contabilidade' && group.name.trim() !== 'Newdin - wave'
})
for (const group of filterGrupos) {
console.log(group.id._serialized)
console.log(group.name)
if(group.name == 'Wave - EMPRESÁRIO ON') continue
await client.sendText(group.id._serialized,
"*Bom dia pessoal!*\n\n" +
"Estamos com nossa campanha de treinamentos de nota fiscal de produto no ar!\n\n" +
"Os treinamentos estão disponíveis para vocês da contabilidade e também para os seus clientes.\n\n" +
"Façam suas inscrições por este link:"
).then(()=>{
console.log(`Enviado para ${group.name}`)
}).catch(()=>{
console.log(`Erro ao enviar para ${group.name}`)
})
await client.sendImage(group.id._serialized, './campanha.jpeg').then(()=>{
console.log(`Enviado para ${group.name}`)
}).catch(()=>{
console.log(`Erro ao enviar para ${group.name}`)
})
}
console.log('Acabou!')
}
async function getGroups(client) {
const chats = await client.getAllChats()
const groups = chats.filter(chat => {
return chat.isGroup
})
return groups
}
It's like the loop stops at "await sendImage" and doesn't continue.
I removed the "sendImage" and left to send only the "sendText", even so, when it gets to the next value in the array, it crashes.