Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

702
Visualizações
Why do I get a 400 error when i'm trying to edit an inline keyboard (node-telegram-bot-api)?

I am making a message with a simple inline keyboard. The expected result would be that when I click on the button it changes together with the message text.

However the button doesn't change and i get this error:

TelegramError: ETELEGRAM: 400 Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message

I am using the node-telegram-bot-api package.

The code that has to change my keyboard is:

let info_message = {
    text: "some info boi",
    keyboard: {
        reply_markup: {
            inline_keyboard: [
                [{ text: 'Start', callback_data: '!/start' }]
            ]
        }
    }
}

client.on("callback_query", async (cb) => {
    if (cb.data === "!/info") {
        const msg = cb.message;
        const opts = {
            chat_id: msg.chat.id,
            message_id: msg.message_id,
        };
        await client.editMessageReplyMarkup(info_message.keyboard, opts);
        await client.editMessageText(info_message.text, opts);
    }
})

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found out the error.

The method editMessageReplyMarkup() requires the parameter replyMarkup, A JSON-serialized object for an inline keyboard.

My mistake was that I gave the whole reply_markup while I was requested to give only the inline_keyboard. The code now looks like this:

client.on("callback_query", async (cb) => {
    if (cb.data === "!/info") {
        const msg = cb.message;
        const opts = {
            chat_id: msg.chat.id,
            message_id: msg.message_id,
        };
        await client.editMessageReplyMarkup(info_message.keyboard.reply_markup, opts); // I gave info_message.keyboard.reply_markup as input, instead of info_message.keyboard
        await client.editMessageText(info_message.text, opts);
    }
})

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda