Answer the question
In order to leave comments, you need to log in
How to display new messages from the VK group using the vk-io library?
I have been trying for several days now to figure out how to display messages from the VK group (not mine).
If you help, I will be grateful.
Answer the question
In order to leave comments, you need to log in
The include method checks for the presence of the same value in the array, for any new object (which it is after receiving a response from the API), this property will always be false, check for the presence of an object in the array by other values, for example, by a link {owner_id}_{id}
ordate
const { VK } = require('vk-io')
const vk = new VK({token: 'тут токен'});
let array = [];
setInterval( async function () {
let response = await vk.api.wall.get({owner_id: -тут id группы, count: 1})
if (response.count === 0) return;
if (array.includes(response.items[0]) === false) {
await console.log(response.items[0])
array.push(response.items[0])
}
}, 1000);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question