Not writing in a file

Hey I am creating a leveling system and I am using a text file (xp.txt) to keep track of the player’s xp. But the problem is that nothing is being written into the file with no errors being shown. `bot.on(‘message’, (message) => {

const fs = require(‘fs’);
const { prefix } = require("./botconfig.json");

fs.writeFileSync(__dirname + ‘/xp.txt’, ‘User: Xp: 0’);
console.log(__dirname + ‘/xp.txt’)

It is located in my index.js file

Hey @Conutik,

The file write is happening, but you need to run refresh in the console to see the changes that took place. This is because the project files are not in sync with the code, and any file modifications created using code requires the refresh command to be run in the console.

Hey, he is right, but, don’t use JSON or txt files as a database, instead use something like SQLite, or quick.db.

1 Like

But how can I make a database using sqlite3 while my discord bot is on an express project??

Just enter in the data. Add a crash script, then when it is all entered put the script back to the main script and run it.

See this -

1 Like

Hey Dude where should I put the directory?? in a new project?? or what

Can you help me do that?

What do you mean by directory?

Do it in the same project. Add a script that just says process.exit() and run that to avoid any 429 errors. If you need any help, with anything else, feel free to DM me.

I personally would recommend using Firebase for storing data.