pre-script: I'm a very noob at javascript and I'm using my c# knoledge to create a Discord bot in javascript, so I'm sorry if this question is too dumb.
I have a code to write down in a json file an array called tarefas
using this code:
tarefas.push(subcomando);
bot.tarefasFile ['wait tasks'] = {
task : tarefas
}
fs.writeFile('./tarefas.json', JSON.stringify(bot.tarefasFile,null,4),
err => {
if (err) throw err;
});
cmd.channel.send('`' + subcomando + '` added to tasks.');
(subcomando
is the message when someone sends w_add task_[subcomando]
in my Discord server. Example below)
The output json file tarefas.json
is:
{
"wait tasks": {
"tasks": []
}
For now, my code resets the value of the array tarefas
when the bot restarts, so I want to reload its values from the tarefas.json file, precisely from the "tasks": []
array. How do I do that?
extra: Example from when the json file is populated with some "tasks":
{
"wait tasks": {
"tasks": [
"hi",
"hello",
"bye",
"math exam tomorrow"
]
}
}