Answer the question
In order to leave comments, you need to log in
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})`
)
)
)
});
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question