O
O
ojiekcahdp2021-02-28 19:59:43
JavaScript
ojiekcahdp, 2021-02-28 19:59:43

How can I handle vk api error?

In general, there is a code:

vk.api.messages.send({
    user_id: msg.senderId,
    message: `Я написал в лс`,
    forward: JSON.stringify({
      peer_id: msg.peerId,
      conversation_message_ids: [msg.conversationMessageId]
    })
  })


In the console I get an error like:
APIError: Code №901 - Can't send messages for users without permission
    at API.callMethod (C:\Users\user\node_modules\vk-io\lib\index.js:828:39)
    at processTicksAndRejections (node:internal/process/task_queues:93:5) {
  code: 901,
  params: [
    { key: 'method', value: 'messages.send' },
    { key: 'oauth', value: '1' },
    { key: 'v', value: '5.103' },
    { key: 'user_id', value: '641618650' },
    {
      key: 'forward',
      value: '{"peer_id":2000000002,"conversation_message_ids":[7552]}'
    },
    { key: 'random_id', value: '64541614530113846' }
  ]
}

How can I correctly handle the error so that the bot does not stop?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2021-03-01
@opium

As always eksepshen and ketch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question