yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.3k stars 1.5k forks source link

setChatMenuButton not working #995

Closed tinsaeDev closed 2 years ago

tinsaeDev commented 2 years ago

Bug Report

I have read:

I am using the latest version of the library.

Expected Behavior

the setChatMenuButton shall set chat's menu button programatically.

Actual Behavior

Instead it is just removing existing menu buttons.

Steps to reproduce the Behavior

        bot.setChatMenuButton( {
            chat_id : chatId,
            menu_button : {
                text : "Order food",
                type:"web_app",
                web_app:{
                    url : "https://tg.elevator.com.et",                                            
                }
            }
        }   );

The above code shall set menu button for the specified chatId

Feature Request

I have:

Introduction

I am building a bot webapp that needs to have a chat bot menu set dynamically

Example

Question

danielperez9430 commented 2 years ago

Hi, @tinsaeDev you need to do JSON.stringify of the menu_button object

sergeycw commented 1 year ago

@danielperez9430 hi! I'm trying to set my menu button like this

bot.setChatMenuButton(
    JSON.stringify({
      chat_id: msg.chat.id,
      menu_button: {
        text: 'Order food',
        type: 'commands',
      },
    }),
  );

and it's not working. I had registered the list of commands with the help of BotFather

Borodin commented 5 months ago

bot.setChatMenuButton( JSON.stringify({ chat_id: msg.chat.id, menu_button: { text: 'Order food', type: 'commands', }, }), );

bot.setChatMenuButton(
{
chat_id: msg.chat.id,
menu_button: JSON.stringify( {
text: 'Order food',
type: 'commands',
},
}),
);
Comandante7s commented 5 months ago

bot.setChatMenuButton( JSON.stringify({ chat_id: msg.chat.id, menu_button: { texto: 'Pedir comida', tipo: 'comandos', }, }), );

bot.setChatMenuButton(
    {
      chat_id: msg.chat.id,
      menu_button: JSON.stringify( {
        text: 'Order food',
        type: 'commands',
      },
    }),
  );

Hola, recien agrego, no muestra error alguno pero tampoco el boton. Saludos.