K
K
kuzubina2019-06-18 12:07:46
JavaScript
kuzubina, 2019-06-18 12:07:46

How to check if a value exists in Markdown markup when sending a Telegram bot message?

Hello!
Forming the body of the message to be sent by the bot

let md = `
  game #_${data.game}_
  Раунд: ${body.event.roundInfo.name} (${body.event.roundInfo.round})
`;
 bot.sendMessage(chat_id, md, {parse_mode: 'Markdown'});

the values ​​are taken from the array, and if for example there is no such value ${body.event.roundInfo.name} in the array, the script will stop and an error will be thrown.
How can I check for these values ​​here? if they are not present, then do not display this line

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