T
T
toasters2019-03-23 07:15:55
JavaScript
toasters, 2019-03-23 07:15:55

How to exclude characters from the response?

I receive a response from the server and send it to VKontakte, sometimes the response comes with color codes:
kj15D2KgNxI.jpg
§6 - the color code itself.
There are several color codes (§1-9, ax), you must send a response without them

vk.updates.hear(/^(?:rcon)\s?([^]+)?/i, async (message) => {
  if (users.includes(message.senderId)) {
  await rcon.connect();
  const response = await rcon.send(`${message.$match[1]}`);
  return Promise.all([
    message.send(` Ответ от сервера:`),
    message.send(response),
    rcon.disconnect()
  ]);
} else {
  message.send('⚠ У вас нет прав!');
}
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-03-23
@toasters

response = response.replace(/§./g, '');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question