A
A
adrenalinruslan2020-01-16 20:54:28
JavaScript
adrenalinruslan, 2020-01-16 20:54:28

Don't want to send node-vk-bot-api message?

I use node-vk-bot-api
The logic of the code is very simple, a request is made to the database to obtain records. If the records were found, then buttons are created in the loop and these buttons are sent to the user. Also, if the records were not found, or were found (anyway), a message is sent to the user with the number of records found. But the second message does not want to be sent. It is sent only when I add it in the code console.log(ctx), but if it is removed, then the second message will not be sent

if(data.length > 0) {
        data.forEach((item) => {
          keyboards.push(`${item.name.first} ${item.name.last}`);
        });
        bot.sendMessage(ctx.message.from_id, 'Все пользователи ( Нажмите на пользователя для удаления его из базы данных ):', undefined, Markup.keyboard(keyboards, { columns: 2 }).inline());
      }

      console.log(ctx);

      /* */
      bot.sendMessage(ctx.message.from_id, `Общее количество пользователей: ${data.length}`, undefined, Markup.keyboard([
        'Добавить', 'Главное меню'
      ]));

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question