0

help me understand what the problem is. Why are the buttons (menuOptions) not displayed?

if (text === '/start') {
                ust[chatId] = 0;
                bot.sendMessage(chatId, `${msg.from.first_name}, <b>Добро пожаловать</b> ✌️\n\nДоступные возможности:`, {
                    parse_mode: "HTML",
                    menuOptions
                })
            }

Code menuOptions:

module.exports = {
    menuOptions: {
        reply_markup: JSON.stringify({
            inline_keyboard: [
                [{text: 'Списки', callback_data: '/list'}],
                [{text: 'Частые вопросы', callback_data: '/quests'}, {text: 'Распространенные проблемы', callback_data: '/problems'}]
            ]
        })
    }

node-telegram-bot-api on Node JS

I tried many ways, remade the menuOptions structure, as soon as I did not insert it.

kh0dan
  • 1

1 Answers1

0

Your code specifies menuOptions key-value pair in the options parameter of the sendMessage method. What you need to do is directly use reply_markup key.

const { menuOptions } = require('./path/to/menu_options');

if (text === '/start') {
    ust[chatId] = 0;
    bot.sendMessage(chatId, `${msg.from.first_name}, <b>Добро пожаловать</b> ✌️\n\nДоступные возможности:`, {
        parse_mode: "HTML",
        reply_markup: menuOptions.reply_markup
    })
}

If you want to use other properties than just reply_markup in the menuOptions object, javascript spread operator might help:

{
    parse_mode: 'HTML',
    ...menuOptions
}
druskacik
  • 2,176
  • 2
  • 13
  • 26