E
E
egorlisss2019-03-24 10:10:37
JavaScript
egorlisss, 2019-03-24 10:10:37

How to return different messages for different responses?

vk.updates.hear(/^(?:СП)\s?([^]+)?/i, (message) => { 
 axios.get(`https://minecraft-statistic.net/api/player/info/${message.$match[1]}/182507`).then(res => {
  if(res.data && res.data.status) {
    let status = res.data.status || 0
  }
return message.send(`${status}`);
}).catch(err => message.send(`⚠ Произошла ошибка!\n\n Возможно вы использовали в никнейме русские буквы!\n Если это не так свяжитесь с *egorlisss`));
});

If status = ok we return one response, if status = error we return another response

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-03-24
@egorlisss

If status = ok we return one response, if status = error we return another response

Is this a JavaScript question? Then the conditional operator will suit you:
PS According to your questions, it seems that you are sawing this vk.updates.hear of yours without knowing JS at all. Isn't it easier to hire a specialist or at least learn the basics?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question