My current code is below.
bot.on('message', mssg => {
io.emit('chat message', `${mssg.author.tag} - ${mssg.content}`);
var message = mssg.content.toLowerCase()
if(shydudearray.includes(message)) {
var newMsg = message.replace(" ", "");
fs.readFile('./assets/data/shydude.json', (err, data) => {
if (err) throw err;
let counter = JSON.parse(data);
x = counter[newMsg];
data[newMsg] = '2';
console.log(`Before: ${x}\nAfter: ${counter[newMsg]}`)
});
}
});
I want to grab my JSON file and get the current number, then +1 to the current number, and save it to the JSON file. Using FS/Javascript, how could I get this to work?