VK API ошибка метода wall.createComment Node.JS
Писали бота по документации VK-IO. Бот работал как надо. После обновления библиотеки начали вылезать ошибки, поправили все согласно новой документации. Однако vk.api.wall.createComment не отрабатывает. Как можно поправить ошибку?
let { VK, resolveResource } = require('vk-io');
let sample = (array) => array[Math.round((array.length - 1) * Math.random())];
let { TOKEN, GROUPS, PHRASES, MILLISECONDS, COMMENT_NUM, COMMENT_TIMEOUT } = require('./config');
let vk = new VK({
token: TOKEN,
});
console.log('> Бот запущен.');
let commented = [];
let ids = [];
(async () => {
ids = await Promise.all(GROUPS.map(async (link) => {
let res = await resolveResource({api: vk.api, resource: link});
if (!res || res.type !== 'group') throw new Error('Ссылка должна вести на группу');
return -res.id;
}));
setInterval(async () => {
let { items } = await vk.api.newsfeed.get({ filters: 'post', count: 1 });
let post = items[0];
if (!ids.includes(post.source_id) || commented.includes(post.post_id)) return;
commented.push(post.post_id);
try {
//for (let i = 0; i < COMMENT_NUM; i++) {
// let message = sample(PHRASES);
// await vk.api.wall.createComment({ owner_id: post.source_id, post_id: post.post_id, message });
// console.log(`> Был оставлен комментарий <<${message}>>`);
// setTimeout(() => {}, COMMENT_TIMEOUT);
// }
let message = sample(PHRASES);
console.log(post.source_id, post.post_id, message)
vk.api.wall.createComment({ owner_id: post.source_id, post_id: post.post_id, message });
console.log('сообщение '+message)
} catch (e) {
let errors = {
212: 'Access to post comments denied',
213: 'Нет доступа к комментированию записи (возможно, комментарии были закрыты)',
222: 'Запрещённые гиперссылки',
223: 'Превышен лимит комментариев на стене',
};
let error = errors[e.code] || 'Неизвестная ошибка';
throw new Error(error);
}
}, MILLISECONDS);
})();
Ошибки:
(node:21352) UnhandledPromiseRejectionWarning: APIError: Code №29 - Rate limit reached
at SequentialWorker.execute (C:\Users\User\node_modules\vk-io\lib\index.js:1584:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:21352) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21352) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.