onAddedToGroup Is not working #1413
ferhacks posted onGitHub
<!-- READ THIS FIRST: - Make sure you are running the latest version of @open-wa/wa-automate before reporting an issue. - Provide as many details as possible. Paste logs, configuration samples and code into the backticks. DO NOT DELETE ANY TEXT from this template! Otherwise, your issue may be closed without comment. -->
Describe the bug
In more recent versions The variable onAddedToGroup
has not been working
Steps to Reproduce 1.Start bot (npm start) 2.Add to a group 3.The bot does not give a response when added, but the commands work
create() code This is the code you use to create the client. e.g
const canvas = require('canvas-constructor')
const fs = require('fs-extra')
const kconfig = require('./config')
const options = require('./options')
const color = require('./lib/color')
const { sleep } = require('./lib/functions')
const config = require('./lib/config/config.json')
const welkom = JSON.parse(fs.readFileSync('./lib/config/welcome.json'))
const bklist = JSON.parse(fs.readFileSync('./lib/config/anti.json'))
const anti = JSON.parse(fs.readFileSync('./lib/config/blacklist.json'))
const fks = JSON.parse(fs.readFileSync('./lib/config/fake.json'))
// Cria um cliente de inicialização da BOT
const start = (kill = new Client()) => {
console.log(color('\n[DEV]', 'red'), color('- +52 9984 9077 94 <-> https://chat.whatsapp.com/Dwu4XpOYOGCDHYDlSoZZG0'))
console.log(color('[Íris]', 'red'), color('[Samu330] READY... Ya puedes usar coamndos\n'))
// Forçar recarregamento caso obtenha erros
kill.onStateChanged((state) => {
console.log('[Estado da Íris]', state)
if (state === 'UNPAIRED' || state === 'CONFLICT' || state === 'UNLAUNCHED') kill.forceRefocus()
})
// Le as mensagens e limpa cache
kill.onMessage((async (message) => {
kill.getAmountOfLoadedMessages()
.then((msg) => {
if (msg >= 3000) {
kill.cutMsgCache()
}
})
kconfig(kill, message)
}))
// Funções para caso seja adicionada em um grupo
kill.onAddedToGroup(async (chat) => {
const wlcmsg = `Hola! \nMe solicitaron como BOT para este grupo, y estaré a su disposición! 烙\nSi quieres ver mis funciones usa ${config.prefix}menu!`
const lmtgru = await kill.getAllGroups()
let totalMem = chat.groupMetadata.participants.length
if (chat.groupMetadata.participants.includes(config.owner)) {
await kill.sendText(chat.id, wlcmsg)
} else if (gc.length > config.memberLimit) {
await kill.sendText(chat.id, `Un nuevo grupo, 7u7! \nLástima que no tenga el requisito, que es tener al menos ${config.memberLimit} miembros. Tú tienes ${totalMem}, reune más gente! `)
await kill.leaveGroup(chat.id)
await kill.deleteChat(chat.id)
} else if (lmtgruc.length > config.gpLimit) {
await kill.sendText(chat.id, `Lo sentimos, estamos en grupos máximos!\nActualmente estamos en ${lmtgru.length}/${config.gpLimit}`)
await kill.leaveGroup(chat.id)
await kill.deleteChat(chat.id)
} else {
kill.sendText(chat.id, wlcmsg)
}
})
// Bloqueia na call
kill.onIncomingCall(async (call) => {
await kill.sendText(call.peerJid, `Que pena! Las llamadas no son compatibles y dificultan mucho! \nTe bloqueé para evitar digustos, contacta al dueño wa.me/${config.owner.replace('c.us', '')} para desbloquear. `)
await kill.contactBlock(call.peerJid)
})
}
create(options(true, start))
.then((kill) => start(kill))
.catch((err) => new Error(err))
Expected behavior I expected the bot to be added to give a welcome response DEBUG INFO
Debug Info { WA_VERSION: 2.2106.5, PAGE_UA: WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36, WA_AUTOMATE_VERSION: 3.6.13, BROWSER_VERSION: Chrome/88.0.4324.182 }
Screenshots
Host (please complete the following information):
- OS: [Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-65-generic x86_64)]
Additional context This variable onAddedToGroup worked in 3.2.4
I have seen that nobody else had put it, so it only happens to me?
thanks