I am trying to make a command command that allows the author to set up a command for their server, This is meant to update a json file not overwrite it, I am using node.js and discord.js
const fs = require('fs')
module.exports = {
name: 'setsuggest',
execute(client, message, args, discord, cmd){
const channelid = args[0]
const serverid = message.guild.id
fs.readFile('suggest.json', function (err, JsonData) {
var json = JSON.parse(JsonData)
let data = {
[serverid]: channelid
};
json.push(data)
fs.writeFile('suggest.json', JSON.stringify(json), function (err) {
if (err) throw err;
console.log('Updated')
})
})
}
}
What am I doing wrong?