Telegraf: Get message_id

Created on 12 Jun 2017  路  3Comments  路  Source: telegraf/telegraf

How can I get the message_id of a message that my bot sent?
var msg = ctx.reply(ctx.from.id, 'test message')
and then?

In order to delete that message again with ctx.deleteMessage().

question

Most helpful comment

@Bostrot you don't need to use messageId in reply* methods, they already know that id.
Same with ctx.deleteMessage() - this method will delete current message, but if you want to delete another one, use ctx.telegram.deleteMessage(chatId, messageId) instead.
Current chatId/messageId you can find in ctx.chat.id/ctx.message.message_id

All 3 comments

@Bostrot you don't need to use messageId in reply* methods, they already know that id.
Same with ctx.deleteMessage() - this method will delete current message, but if you want to delete another one, use ctx.telegram.deleteMessage(chatId, messageId) instead.
Current chatId/messageId you can find in ctx.chat.id/ctx.message.message_id

@dotcypress Thank you! but I am feeling kinda stupid now.
bot.command('start', ({ reply, deleteMessage }) => { reply('test message') setTimeout(function() { deleteMessage() }, 2000) })

this doesn't delete the message. it returns:

Error(${method} is not available for ${this.updateType})
^

Error: deleteMessage is not available for message

what's wrong with it?

@Bostrot because bot can't delete users message, and this method allowed only for callback_query updates.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aminjoharinia picture aminjoharinia  路  3Comments

supermomme picture supermomme  路  3Comments

Stephirio picture Stephirio  路  3Comments

jwandekoken picture jwandekoken  路  3Comments

trgwii picture trgwii  路  3Comments