yuvapoojary / telegram.js

A powerfull JavaScript library for interacting with telegram bot API
https://telegram.js.org
Apache License 2.0
4 stars 3 forks source link

Error when you try sending message on channel #8

Open IKA-Syrian opened 2 years ago

IKA-Syrian commented 2 years ago

/home/darkmen/Telegram-bot/node_modules/@yuva1422/telegram.js/src/structures/Message.js:93 this.member = this.chat.members.add(this.chat.id, { id: data.from.id, extras: [{ user: data.from }] }); ^

TypeError: Cannot read properties of undefined (reading 'id') at Message._patch (/home/darkmen/Telegram-bot/node_modules/@yuva1422/telegram.js/src/structures/Message.js:93:71) at new Message (/home/darkmen/Telegram-bot/node_modules/@yuva1422/telegram.js/src/structures/Message.js:41:20) at WorkerClient.onMessage (/home/darkmen/Telegram-bot/node_modules/@yuva1422/telegram.js/src/client/WorkerClient.js:39:21) at WorkerClient.processUpdate (/home/darkmen/Telegram-bot/node_modules/@yuva1422/telegram.js/src/client/WorkerClient.js:27:12) at /home/darkmen/Telegram-bot/node_modules/@yuva1422/telegram.js/src/client/PollingClient.js:50:30 at processTicksAndRejections (node:internal/process/task_queues:96:5) [nodemon] app crashed - waiting for file changes before starting...

yuvapoojary commented 2 years ago

Please provide reproducable code

PopeNobody commented 2 years ago

To reproduce:

1) Fire up the "ping" sample. 2) Create a telegram channel (in my case it was a private channel, but I doubt it matters). 3) add the bot to the channel. Allow it to receive messages. 4) send any message on the channel. 5) watch the poor bot die.

If you change line 93 to:

if(data.from !=null) 
  this.member = this.chat.members.add(this.chat.id, { id: data.from.id, extras: [{ user: data.from }] }); 

Then channel messages work.

I think that channel messages are just from the channel, not from a user.