Ok, so I am making a Discord bot with node.js, and in my bot, I am trying to add 1 to the ticket numbers so a user will have a number when they submit their ticket, and I am storing this number in a .json file. When I make any changes to my code, or restart the web server, the number resets. I have also noticed the .json file isn't changing, only the number. I know that .json isn't the way to go for this problem, but I know it works, and I don't need much out of it, if you could look at my code and see my issue, help me out please.
CODE:
const Discord = require("discord.js");
const fs = require("fs");
const num = require("./numbers.json");
const fileName = "./numbers.json";
const file = require(fileName);
exports.run = (client, message, args, member) => {
if (args[0] === undefined) {
var embed = new Discord.RichEmbed()
embed.setColor(0xFF0000);
embed.addField("ERROR", "You did not specify a reason!", false);
message.channel.send(embed);
message.react("❎");
}
else {
var arg = args.join(" ")
file.ticket = num.ticket + 1;
fs.writeFile(fileName, JSON.stringify(file), function (err) {
if (err) return console.log(err);
console.log(JSON.stringify(file));
console.log('writing to ' + fileName);
});
var embed = new Discord.RichEmbed()
embed.setColor(0x00AE86);
embed.setTitle(arg + " *(#" + num.ticket + ")*");
embed.setFooter(`Submission by @${message.author.tag}`, message.author.displyAvatarURL)
client.channels.get("566996295768735745").send(embed)
message.react("✅");
message.channel.send("Your ticket has been submitted! *(#0)*")
}
}```