E
E
egorlisss2019-03-22 19:12:47
JavaScript
egorlisss, 2019-03-22 19:12:47

Send response only to certain users?

How to allow only certain users to use a command?

vk.updates.hear(/^(?:rcon)\s?([^]+)?/i, async (message) => {
    await rcon.connect();

    const response = await rcon.send(`${message.$match[1]}`);

    return Promise.all([
      message.send(` Ответ от сервера:`),
        message.send(response),
        rcon.disconnect()
    ]);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-03-22
@egorlisss

let users = [1, 2, 3, 4, 5]; // определённые пользователи

vk.updates.hear(/^(?:rcon)\s?([^]+)?/i, async (message) => {
  if (!users.includes(message.senderId))
    return; 

  await rcon.connect();

  const response = await rcon.send(`${message.$match[1]}`);

  return Promise.all([
    message.send(` Ответ от сервера:`),
    message.send(response),
    rcon.disconnect()
  ]);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question