pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.05k stars 3.58k forks source link

Error when running code #1818

Closed ricdim4 closed 9 months ago

ricdim4 commented 1 year ago

Is there an existing issue for this?

Describe the bug

When I run, I get this error:

npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\HP\AppData\Roaming\npm-cache\_logs\2022-11-18T22_15_59_058Z-debug.log

Then I do node index.js in the terminal and I get the QR, but the bot doesn't work.

I tried changing scripts and modified line 17 in Injected.js but it doesn't work.

Expected behavior

I expected a message saying it ran correctly.

Steps to Reproduce the Bug or Issue

  1. Do npm start
  2. See error

Relevant Code

const qrcode = require('qrcode-terminal');

const { Client } = require('whatsapp-web.js'); const client = new Client();

client.on('qr', qr => { qrcode.generate(qr, {small: true}); });

client.on('ready', () => { console.log('Client is ready!'); });

client.on('message', message => { if(message.body === 'hola'||'Hola'||'buenas'||'Buenas'||'hello'||'Hello') { message.reply('test'
'test.'
'test'); } });

client.initialize();

Browser Type

Other (please write in Additional Context)

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows 10 Phone OS: Android whatsapp-web.js version 1.18.3 Node.js Version v12.13.0

Additional context

Browser: Microsoft Edge

maunklana commented 1 year ago

why run "npm start"?

here the error

client.on('message', message => {

  if(message.body === 'hola'||'Hola'||'buenas'||'Buenas'||'hello'||'Hello') {

    message.reply('test'

   'test.'

   'test');
  }
});

you want a new line? try this.

client.on('message', message => {

  if(message.body === 'hola'||'Hola'||'buenas'||'Buenas'||'hello'||'Hello') {

    message.reply("test\ntest.\ntest");
  }
});
ricdim4 commented 1 year ago

Yeah, thank you. Now the bot works correctly, but I got the same error. I don't know if that error will be a problem later.