Node-telegram-bot-api: Unhandled rejection error: 400

Created on 20 Jul 2016  路  5Comments  路  Source: yagop/node-telegram-bot-api

Whrn i transfer created bot object to another module/object, then i get this error

`bot.on('message', function (msg) {
var chatId = msg.chat.id;
var from = msg.from;
console.log(from);

var member = new Member(from);
member.on('ready', () => {

    bot.sendMessage(from.id, member.firstName+' You say: '+msg.text); // this works fine
    member.update(bot, msg); // this not working, inside the same code that line above 
    member.save();
})

});
`

Unhandled rejection Error: 400 {"ok":false,"error_code":400,"description":"Bad R
equest: Message text is empty"}
at \bot\telegram\node_modules\node-telegram-b
ot-api\src\telegram.js:136:15
at tryOnImmediate (timers.js:543:15)
at processImmediate as _immediateCallback
From previous event:
at TelegramBot._request (\bot\telegram\node_m
odules\node-telegram-bot-api\src\telegram.js:134:6)
at TelegramBot.sendMessage (\bot\telegram\nod
e_modules\node-telegram-bot-api\src\telegram.js:235:15)
at RootFSM.greeting (\bot\telegram\fsm\root.j
s:26:22)
at eval (eval at update (\bot\telegram\member
.js:152:27), :1:5)
at Member.update (\bot\telegram\member.js:152
:3)
at Member.member.on (\bot\telegram\app4.js:36
:16)
at emitNone (events.js:86:13)
at Member.emit (events.js:185:7)
at Member.load.then.resolve (\bot\telegram\me
mber.js:20:9)

What problem in this code?
Thx

sorry! my bad!

Most helpful comment

@Tpona you could just close the issue yourself.

All 5 comments

All correct, it's my error!
I just pointed the wrong first parameter as message text instead chat.id.
i'm sorry, Issue can be closed.

@Tpona you could just close the issue yourself.

how to send message in chanel

error:

Unhandled rejection Error: ETELEGRAM: 400 Bad Request: chat not found
at request.then.resp (/home/reza/gitbot/node_modules/node-telegram-bot-api/src/telegram.js:181:15)
at tryCatcher (/home/reza/gitbot/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/reza/gitbot/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/reza/gitbot/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/reza/gitbot/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/reza/gitbot/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/reza/gitbot/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/reza/gitbot/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/reza/gitbot/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

@rezabojnordi Please be creating new issues (after searching through existing ones, of course). Besides that, the error says chat not found. You are probably using a wrong chat ID.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Panthro picture Panthro  路  3Comments

alikhil picture alikhil  路  3Comments

jacopocappelli1989 picture jacopocappelli1989  路  4Comments

Rezania815 picture Rezania815  路  3Comments

FerX picture FerX  路  4Comments