Editing Inline MessagesBOT-ONLY
Bot Walkthrough 8 of 18
Bots can edit inline messages after a user selects an inline query result or interacts with an inline keyboard.
Editing the Text
In a chosenInlineResult or callbackQuery handler, use the context shortcut for editInlineMessageText.
client.on("chosenInlineResult", async (ctx) => {
await ctx.editInlineMessageText("Updated content.");
});
Editing the Caption
The context shortcut for editInlineMessageCaption updates the caption.
client.on("chosenInlineResult", async (ctx) => {
await ctx.editInlineMessageCaption({ caption: "New caption." });
});
Editing the Reply Markup
The context shortcut for editInlineMessageReplyMarkup lets you change the inline keyboard.
client.callbackQuery("refresh", async (ctx) => {
await ctx.editInlineMessageReplyMarkup({
replyMarkup: [[{ text: "Refreshed", callbackData: "done" }]],
});
await ctx.answerCallbackQuery();
});