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().
@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.
Most helpful comment
@Bostrot you don't need to use
messageIdinreply*methods, they already know that id.Same with
ctx.deleteMessage()- this method will delete current message, but if you want to delete another one, usectx.telegram.deleteMessage(chatId, messageId)instead.Current
chatId/messageIdyou can find inctx.chat.id/ctx.message.message_id