Node-telegram-bot-api: How to implement a delete message fucntion?

Created on 11 Jul 2019  路  2Comments  路  Source: yagop/node-telegram-bot-api

This code doesn't work, I have added bot to a group and make it as an admin

bot.onText(/hi/gi, msg => {
  bot.deleteMessage(msg.message_id)
})

Error

Unhandled rejection Error: ETELEGRAM: 400 Bad Request: message identifier is not specified
    at /home/usama/Documents/back-end/telebot/node_modules/node-telegram-bot-api/src/telegram.js:280:15
    at tryCatcher (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/promise.js:699:18)
    at _drainQueueStep (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/usama/Documents/back-end/telebot/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (internal/timers.js:439:21)

Most helpful comment

let chat_id = msg.chat.id;
let message_id = msg.message_id;
bot.deleteMessage(chat_id, message_id);

you should do like this in groups to delete the message ....

All 2 comments

let chat_id = msg.chat.id;
let message_id = msg.message_id;
bot.deleteMessage(chat_id, message_id);

you should do like this in groups to delete the message ....

let chat_id = msg.chat.id;
let message_id = msg.message_id;
bot.deleteMessage(chat_id, message_id);

you should do like this in groups to delete the message ....

this works, thanks a lot friend

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kenanchristian picture kenanchristian  路  4Comments

saeedhei picture saeedhei  路  4Comments

dimawebmaker picture dimawebmaker  路  3Comments

Rezania815 picture Rezania815  路  3Comments

sidelux picture sidelux  路  3Comments