S
S
Sergey2020-06-18 19:03:48
JavaScript
Sergey, 2020-06-18 19:03:48

VK-IO: how to send an image to a group conversation?

In normal conversations, the context.sendPhotos(photo) method works without problems, but in group conversations, I get an "Unknown error occurred" error in response. How can I fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MyAngelRem, 2020-06-19
@bit0r1n

const { VK } = require('vk-io');

const vk = new VK({
    token: config.vkToken,
    pollingGroupId: config.vkGroupId
});

vk.upload
  .messagePhoto({
    source: buffer, //картинка, в моём случае из буффера
  })
  .then((attachment) =>
    vk.api.messages.send({
      message: text_message, //сообщение
      attachment,
      peer_id: 2000000003, // id беседы
    })
  );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question