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)
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
Most helpful comment
you should do like this in groups to delete the message ....