A
A
Amin Aliyev2019-04-30 20:58:57
Node.js
Amin Aliyev, 2019-04-30 20:58:57

How to make a response to an unknown command?

I use vk-io

updates.hear(/мой счёт/i, async (context) => {
  await context.send(`Ваш счёт: ${Math.floor(context.user.balance)}`);
});
updates.hear(/магазин/i, async (context) => {
  await context.send(`Вы перешли в раздел магазина`, {
  keyboard:
  Keyboard.keyboard([
    [
      Keyboard.textButton({
        label: 'Улучшения',
        color: Keyboard.POSITIVE_COLOR
      })
    ],
      Keyboard.textButton({
        label: 'Назад',
        color: Keyboard.DEFAULT_COLOR
      })
    ])
  });
});

If the command is not in updates.hear then send a message: "there is no such command"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-04-30
@amin4ik_03

from the library documentation :

updates.setHearFallbackHandler(async (context, next) => {
  await context.send('Такой команды нет :(');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question