#FS Help

1 messages · Page 1 of 1 (latest)

versed goblet
#

Hey there I am trying to use .append on an array that is stored on a local JSON file that I am importing using FS.
Here is what I have:

async execute(interaction, client) {
       await fs.readFile('C:/Users/24gav/Bot1/config.json', 'utf8', function readFileCallback(err, data){
           if (err){
               console.log(err);
           } else {
               obj = JSON.parse(data);
               obj.ignoredUsers.append(interaction.options.getUser('blockuser').id)
               json = JSON.stringify(obj); 
               fs.writeFile('C:/Users/24gav/Bot1/config.json', json, function(err) {if (err) throw err;});
           }
       })
   }
}```
This is the error:
```bash
C:\Users\24gav\Bot1\commands\blockuser.js:15
               obj.ignoredUsers.append(interaction.options.getUser('blockuser').id)
                                ^

TypeError: obj.ignoredUsers.append is not a function
   at readFileCallback (C:\Users\24gav\Bot1\commands\blockuser.js:15:34)
   at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)

Node.js v17.4.0```
and here is the file:
```json
{
   "clientId": "1049423981872173097",
   "guildId": "1047972498236506122",
   "token": "Not for you",
   "reportChannel": "1052684503543447702",
   "mangReportChannel": "1055522372893020190",
   "staffRolePing": "1049806596772990976",
   "reportsCategory": "1051976955035140196",
   "archive": "1052788193495363625",
   "managementReportsCategory": "1052334996322529331",
   "managementRolePing": "1055447165880762368",
   "everyone": "1047972498236506122",
   "ignoredUsers": []
}```
#

I know its not Discord.JS related but I am using Discord.JS in the project and the people here answer the fastest so...