title: Save JSON file to grab other data from it later
body: <p>I want to be able to save my json file with new data and then call upon that data so that I can save new data again. Right now all it is doing is it is, when I call upon any part of the JSON file's data, staying the same the last time I manually saved it. (I did edit some code and a better description of my problem) Thank you in advance! Here is my code there is no error log: </p>
  
  <pre><code>const Discord = require('discord.js');
  const botconfig = require("./botconfig.json");
  const fs = require("fs");
  const bot = new Discord.Client();
      bot.on("message", async message =&gt; {
          let prefix = botconfig.prefix;
          let messageArray = message.content.split(" ");
          let cmd = messageArray[0];
          let args = messageArray.slice(1);
          console.log(message.member.id)
          var playerFile = require(`./playerData/${message.member.id}.json`);
          if (message.author.bot) return;
          if (message.channel.type === "dm") return;
          if (cmd.charAt(0) === prefix) {
              if(cmd === `${prefix}fc`){
                  fs.exists(`./playerData/${message.member.id}.json`, function(exists) {
                      if(exists){
                      let ar = args[0];
                      let ninConsole = args[1];
                      let code = args[2];
                      if(ar === "add" || ar === "remove"){
                          if(code){
                              if(ar === "add"){
                                  console.log("Add");
                                  if(ninConsole === "switch"){
                                      console.log("Switch " + code); 
                                      let fileContent = `{"switch": "${code}","threeDS": "${playerFile.threeDS}"}`
                                      fs.writeFile(`./playerData/${message.member.id}.json`, fileContent, (err) =&gt; {
                                          if (err) {
                                              console.error(err);
                                              return;
                                          };
                                      });
                                  }
                                  if(ninConsole === "3ds"){
                                      let fileContent = `{"switch": "${playerFile.switch}","threeDS": "${code}"}`
                                      fs.writeFile(`./playerData/${message.member.id}.json`, fileContent, (err) =&gt; {
                                          if (err) {
                                              console.error(err);
                                              return;
                                          };
                                      });
                                  }
                              }
                              if(ar === "remove"){
                                  if(ninConsole === "switch"){
                                      let fileContent = `{"switch": "None","threeDS": "${playerFile.threeDS}"}`
                                      fs.writeFile(`./playerData/${message.member.id}.json`, fileContent, (err) =&gt; {
                                          if (err) {
                                              console.error(err);
                                              return;
                                          };
                                      });
                                  }
                                  if(ninConsole === "3ds"){
                                      let fileContent = `{"switch": "${playerFile.switch}","threeDS": "None"}`
                                      fs.writeFile(`./playerData/${message.member.id}.json`, fileContent, (err) =&gt; {
                                          if (err) {
                                              console.error(err);
                                              return;
                                          };
                                      });
                                  }
                              }
                          }
                      }
                  }else{
                      return;
                  }
                  });
              }
  </code></pre>