title: How to reset a file edited with edit-json-file
body: <p>I've been working on this queue for a discord.js bot. What it does it someone does !smm submit  and then it will add it to the JSON file like so:</p>
  
  <pre><code>"1": "id",
  "2": "anotherid"
  </code></pre>
  
  <p>Then if a person were to do !smm delete it would remove the first item in the list. For some reason if I do that it will keep the same amount of objects but instead it will duplicated the last object so if my JSON file was this</p>
  
  <pre><code>"1": "id",
  "2": "anotherid",
  "3": "thisid"
  </code></pre>
  
  <p>It would be at the end</p>
  
  <pre><code>"1": "anotherid",
  "2": "thisid",
  "3": "thisid"
  </code></pre>
  
  <p>If you have a better way for a queue please tell me otherwise here is my code for the command and its subcommands. There is a editJsonFile api installed so when you see "queue.set("foo", "foobar")" foo is the object name and foobar is the object's value:</p>
  
  <pre><code>if(cmd === `${prefix}smm`){
      let type = args[0];
      let a = args[1];
      if(type === "submit"){
          message.delete()
          if(a){
              if(a.charAt(4) === "-" &amp;&amp; a.charAt(9) === "-" &amp;&amp; a.charAt(14) === "-"){
                  for(x = 1; x &lt; 10000; x++){
                      if(!file[x]){
                          console.log(x)
                          queue.set(`${x}`, `${a}`)
                          return;
                      }
                  }
              }else{
                  message.author.send("Sorry but you typed in the ID wrong. Make sure you include these '-' to separate it.")
              }
          }
      }
      if(type === "delete"){
          message.delete()
          let arr = [];
          for(x = 1; x &lt; 10000; x++){
              if(file[x]){
                  arr.push(file[x])
              }else{
  
                  let arrr = arr.slice(1)
                  console.log(arrr)
                  fs.writeFile(`./queue.json`, '{\n    \n}', (err) =&gt; {
                      if (err) {
                          console.error(err);
                          return;
                      };
                  });
                  setTimeout(function(){
  
                      console.log(arrr.length)
                      for(e = 0; e &lt; arrr.length; e++){
                          console.log(`e: ${e} || arrr.length: ${arrr.length}`)
                          queue.set(`${e+1}`, `${arrr[e]}`)
                      }
  
                      return;
                  }, 3000)
                  return;
              }
          }
  
      }
  }
  </code></pre>