G
G
German Shestak2018-09-14 18:45:30
In contact with
German Shestak, 2018-09-14 18:45:30

How to make input/output from json file?

Good day. I am writing a bot for a VK conversation and I need to write data of this format to a file on command.
id - taken from message.date sub
- first argument
hw - second argument
time - third argument As a result, the following message should appear: Monday id. sub - hw Etc. The question is this. How to write all this into a json file, and then output it as I need? I use VK-Promise Here is the code :

vk.on("message",function (event, message) { // Обрабатываем сообщения
  const args = message.body.split(" ").slice(1);
  if (message.body.startsWith(config.prefix + "add")) {
    let sub = args[0]
    let hw = args[1]
    let time = args[2]
    if(!sub||!hw||!time){
      message.send(`Ошибка! Отправьте сообщение по такому шаблону : ${config.prefix}add предмет д\з день недели`)
    }else {
    message.send(`Домашнее задание (${hw}) на (${time}) по ${sub} добвлено!`)
  }
}
});

Thank you for your reply

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-09-14
@ilovetwilight

you can do it, but it will be better to use a database,
it will be much easier and more productive,
even sqlite, even mysql

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question