G
G
German Shestak2018-09-17 22:05:11
In contact with
German Shestak, 2018-09-17 22:05:11

How to create a message from many parts?

Good day, toasters .. toasters .....
Again I am with my noob questions.
It is required to make sure that one message is generated from the code that is obtained and sent.
For VK asks for captcha if you send a lot of messages. And I need it fast.
Actually, here is my shitty code without comments, but I tried to bring it back to normal.

exports.run = (client, message, args) => {
  let stime = args[0];
  let subb = args[1]
   if(!stime&&!subb) {
     client.api.messages.send({
     "message": "Ошибка! Запись не найдена. Возможно, вы не ввели день недели или предмет.Искать можно по дню недели или дню недели и предметы. По-другому пока никак. Если вы уверены",
     "peer_id": message.peer,
     "forward_messages": message.id
     })
  }else if(!subb) {
    var base = client.db.get('homework').filter({time: stime }).sortBy('subject').take(10).value()
    for (i = 0; i < base.length; ++i) {
    var bbase = base[i]
    if(bbase.photo === undefined) {
    try {
    message.send({
    "message" : `id : ${bbase.id}, \nПредмет : ${bbase.subject}\nДень недели : ${bbase.time}\nЗадание : ${bbase.task}`,
    "peer_id": message.peer,
    "forward_messages": message.id
    })
  } catch (err) {
            client.api.messages.send({
    "message": "Ошибка! Запись отсуствует. Возможно вы неверно ввели день недели",
    "peer_id": message.peer,
    "forward_messages": message.id
    })
    }
  }else {
    try {
    message.send({
    "message" : `id : ${bbase.id}, \nПредмет : ${bbase.subject}\nДень недели : ${bbase.time}\nЗадание : ${bbase.task}\nФото : ${bbase.photo}`,
    "peer_id": message.peer,
    "forward_messages": message.id
    })
  } catch (err) {
            client.api.messages.send({
    "message": "Ошибка! Запись отсуствует. Возможно вы неверно ввели день недели",
    "peer_id": message.peer,
    "forward_messages": message.id
    })
    }
}
  }
}else {
  var base = client.db.get('homework').filter({time: stime, subject: subb }).sortBy('subject').take(10).value()
  for (i = 0; i < base.length; ++i) {
  var bbase = base[i]
  if(bbase.photo === undefined) {
  try {
    client.api.messages.send({
      "message" : `id : ${bbase.id}, \nПредмет : ${bbase.subject}\nДень недели : ${bbase.time}\nЗадание : ${bbase.task}\n`,
      "peer_id": message.peer,
      "forward_messages": message.id
    })
  } catch (err) {
            client.api.messages.send({
    "message": "Ошибка! Запись отсуствует. Возможно вы неверно ввели день недели",
    "peer_id": message.peer,
    "forward_messages": message.id
    })
    }
}else {
  try {
    client.api.messages.send({
      "message" : `id : ${bbase.id}, \nПредмет : ${bbase.subject}\nДень недели : ${bbase.time}\nЗадание : ${bbase.task}\nФото : ${bbase.photo}`,
      "peer_id": message.peer,
      "forward_messages": message.id
    })
  } catch (err) {
            client.api.messages.send({
    "message": "Ошибка! Запись отсуствует. Возможно вы неверно ввели день недели",
    "peer_id": message.peer,
    "forward_messages": message.id
    })
    }
}
  /*
  client.api.messages.send({
    "message" : `id : ${bbase.id}, \nПредмет : ${bbase.subject}\nДень недели : ${bbase.time}\nЗадание : ${bbase.task}\nФото : ${bbase.photo}`,
    "peer_id": message.peer,
    "forward_messages": message.id
  */
}
}
};

I use command hadler, which I took from the discord))
It's very convenient, if anyone needs it - write.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
German Shestak, 2018-09-19
@ilovetwilight

varm;
m = m + "text";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question