A
A
Alexander Alexandrov2020-10-12 00:46:24
In contact with
Alexander Alexandrov, 2020-10-12 00:46:24

When I try to get message id, I get error 100, what's the problem?

I am writing a bot in NodeJS, there was a problem. I was going to write a command that will delete the forwarded message.
Here is the code:

cmd.hear(/^(?:-смсс)$/i, async (message, bot) => {
  if (message.hasForwards) {
    await message.loadMessagePayload();
  }
  

  
  
  message.fwds = message.forwards;
message.attachs = message.attachments;

console.log('Forwards', message.fwds[0].text, message.fwds[0].senderId);


  const sms = user.api.messages.search({ q: message.fwds[0].text, peer_id: message.fwds[0].senderId, count: 1 });
user.api.messages.delete({ message_ids: sms.id, delete_for_all: 1 }), (data, error) => {
  if (error) {
     return message.send('Ошибка выполнения метода', error)
  } else {
     console.log(data)
     return message.send('сообщение удалено')
  }
}


});


The bot starts quietly, but when this command is executed, an error pops up:

( node:17647 ) UnhandledPromiseRejectionWarning: APIError: Code №100 - One of the parameters specified was missing or invalid: message_ids is undefined at API.callMethod (/storage/emulated/0/ FBI/node_modules/vk-io/lib/ index.js:1229:33 ) at processTicksAndRejections (internal/process/task_queues.js :93:5 ) ( node:17647) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_reje... ). (rejection id: 5)

what's the problem?

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