TypeError: Cannot read properties of undefined (reading 'session')
See original GitHub issueOlá, estou com um problema na leitura da sessão. Não está gerando o QR CODE… Alguém consegue me ajudar?
import { start } from "repl"
import {create, Whatsapp, Message, SocketState } from "venom-bot"
class Sender {
private client: Whatsapp
constructor()
{
//NAO FOI FEITO NO CONSTRUTOR PRA FICAR MAIS LIMPO E EXPLICITO.
// METODOS DE INICIALIZAÇÃO
this.initialize()
}
async sendText(to: string, body:string)
{
//55dddnumero@c.us
this.client.sendText(to,body)
}
// METODO DE FORA
private initialize()
{
const qr = (base64Qrimg: string) => {}
const status = (statusSession: string) =>
{
// isLogged || notLogged || browserClosed || qrReadSuccess || noOpenBrowser || deleteToken
}
const start = (client: Whatsapp) =>
{
this.client = client
this.sendText("5521982314899@c.us", "Ola, tudo bem? esse é um teste")
}
create('arcane-sender', qr, status)
.then((client)=> start(client))
.catch((error) => console.error(error))
}
}
export default Sender
O ERRO:
TypeError: Cannot read properties of undefined (reading 'session') at C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\src\controllers\initializer.ts:177:48 at step (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:98:23) at Object.next (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:79:53) at C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:73:71 at new Promise (<anonymous>) at __awaiter (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:69:12) at create (C:\Users\Antonio Oliveira\Desktop\JavaScript\node_modules\venom-bot\dist\controllers\initializer.js:117:12) at Sender.initialize (C:\Users\Antonio Oliveira\Desktop\JavaScript\src\sender.ts:37:19) at new Sender (C:\Users\Antonio Oliveira\Desktop\JavaScript\src\sender.ts:11:14) at Object.<anonymous> (C:\Users\Antonio Oliveira\Desktop\JavaScript\src\app.ts:4:16)
Issue Analytics
- State:
- Created a year ago
- Comments:22 (1 by maintainers)
Top GitHub Comments
Realmente se trata de algo da versão 4.0.11, pra resolver é só colocar a versão 4.0.10 conforme o @pedrolucasD disse. npm i --save venom-bot@4.0.10
I solved this problem from version 4.3 by doing the following step: Step 1: Access node_modules/venom-bot/controllers/initializer.js Step 2: remove this.session to session Step 3: save ready