Answer the question
In order to leave comments, you need to log in
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} добвлено!`)
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question