• Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

250
Views
venom-bot - Message send repeat doesn't work

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.

9 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.