A
A
Alexander Arkhangelsky2019-12-09 02:20:18
In contact with
Alexander Arkhangelsky, 2019-12-09 02:20:18

How to get random participants in a VK conversation?

Hello, can you tell me how to get two or more random participants in the conversation? For some reason, I only get one.

vk.updates.hear(/^(?:Кто с кем)\s([^]+)$/i, async (message) => {
  if(!message.isChat) return bot(`команда доступна только в беседе!`);
    let { profiles } = await vk.api.messages.getConversationMembers({
        peer_id: message.peerId
    });
    let profile = getRandomElement(profiles);
    let text = message.$match[1];
    await message.send(
        getRandomElement(['тест', 'тесты']) + (` @id` + `${profile.id} (${profile.first_name} ${profile.last_name}) ` + `${text}` + (` @id` + `${profile.id} (${profile.first_name} ${profile.last_name})`
        )
      )
    )
});

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Arkhangelsky, 2019-12-10
@Wertaer

All in all it needed to be:

...
let profile = getRandomElement(profiles);
let profil = getRandomElement(profiles);
    let text = message.$match[1];
    await message.send(
        getRandomElement(['тест', 'тесты']) + (` @id` + `${profile.id} (${profile.first_name} ${profile.last_name}) ` + `${text}` + (` @id` + `${profil.id} (${profil.first_name} ${profil.last_name})`
        )
      )
    )
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question