A
A
amdkot2020-12-15 22:02:46
JavaScript
amdkot, 2020-12-15 22:02:46

How to register conversations in a VK bot?

How to make it so that after adding a bot to a conversation, the bot appears in the database with its ID. Here are my attempts:

updates.startPolling();
updates.on('message', async (message) => {
if(Number(messages.getChat) <= 0) return;
if(/\[public176715957\|(.*)\]/i.test(message. text)) message.text = message.text.replace(/\[public176715957\|(.*)\]/ig, '').trim();

if(!chat.find(x=> x.id = == messages.getChat))
{
const [chat_info] = await messages.getChat({ peerId: message.peerId });

users.push({
peerId: message.peerId,
uid: chats.length
});
console.log( ` +1 player [Players: ${chats.length}]`);
console.log(``);
saveChats();
}

let chats = require('./database/chats.json');

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