N
N
NoDeJs2292020-05-18 18:21:11
In contact with
NoDeJs229, 2020-05-18 18:21:11

What to make buttons work in VK bot?

In the code below, if not , then the buttons work. And if I add the buttons do not work.if(message.user.bank == 0)return bot (`Пусто`);
if

cmd.hear(/^(?:банк| Банк)$/i, async (message, bot) => {
      const multiply = utils.pick([200,125]);
      const multiply1 = utils.pick([175,25]);
      const multiply2 = utils.pick([50,150]);
      let idey = Math.floor(message.user.balance/multiply);
      let idey2 = Math.floor(message.user.balance/multiply1);
      let idey3 = Math.floor(message.user.balance/multiply2);
      let idey4 = Math.floor(message.user.bank/multiply);
      let idey5 = Math.floor(message.user.bank/multiply1);
      let idey6 = Math.floor(message.user.bank/multiply2);
  return bot(`на балансе в банке ${utils.sp(message.user.bank)}$`,
{ 
  keyboard:JSON.stringify( 
  { 
  "one_time": false, 
  "buttons":[
  [{ 
  "action": { 
  "type": "text", 
    "payload": "{}", 
  "label": ` ${idey}`
  }, 
  "color": "default" 
  }, 
    {
"action": { 
"type": "text", 
"payload": "{}", 
"label": ` ${idey2}`
}, 
"color": "default" 
  }, 
    {
"action": { 
"type": "text", 
"payload": "{}", 
"label": ` ${idey3}`
}, 
"color": "default" 
  }], 
    [{
"action": { 
"type": "text", 
"payload": "{}", 
"label": ` ${idey4}`
}, 
"color": "default" 
  }, 
    {
"action": { 
"type": "text", 
"payload": "{}", 
"label": ` ${idey5}`
}, 
"color": "default" 
  }, 
    {
"action": { 
"type": "text", 
"payload": "{}", 
"label": ` ${idey6}`
}, 
"color": "default"
  }], 
    [{
"action": { 
"type": "text", 
"payload": "{}", 
"label": ` Создать вклад`
}, 
"color": "positive"
  }], 
    [{
"action": { 
"type": "text", 
"payload": "{}", 
"label": `◀ В раздел «Разное»`
}, 
"color": "primary"
  }]
  ]
}) 
});
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
myxomor469, 2020-05-18
@NoDeJs229

move the button block to a separate variable in this place in the code

let idey6 = Math.floor(message.user.bank/multiply2);
const keyboardSettings = {
keyboard:JSON.stringify(       //это твои настройки кнопок
...........
}
if(message.user.bank == 0)return bot (`Пусто`,  keyboardSettings); //в этой строке
// мы все равно отправляем чтобы кнопки отображались
return bot(`на балансе в банке ${utils.sp(message.user.bank)}$`,  keyboardSettings);

and send buttons in both cases

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question