Save arguments/variables to discord account in JSON file Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Save arguments/variables to discord account in JSON file without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m new here and I want to assign username for e.g on execute command !register ‘username’ save it to json file with assigned discord tag/user id and next make command that uses argument ‘username’ from before saved file it is possile on Node.js? I don’t wanna to use sql because it’s blackmagic for me and I don’t have time for it right now.


If you want to use JSON (I highly recommend AGAINST that, I’ve done it myself and I very often had to deal with my JSON’s being completely wiped). use the fs package that comes with Node.

set the file as a blank array and this code will work.

var username = message.content.split(" ")[1];

var oldJSON = JSON.parse(fs.readFileSync("./usersfile.json");
var newJSON = oldJSON.push(`{"username": ${username}, "userID": ${}, "name": ${message.member.username}, "discriminator": ${message.member.discriminator}}`)

fs.writeFileSync(JSON.stringify(newJSON), "./usersfile.json");

Again, I HIGHLY recommend AGAINST using this system as it’s incredibly bug prone. Just learn MySQL or MongoDB. But if you’re willing to take (the immense) risk, that should work.

We are here to answer your question about Save arguments/variables to discord account in JSON file - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji