Why is the recorded file?

Write such code:
const shell = require("discord.js");
const fs = require("fs");
const profile = require("../database.json")
let embed;
const fetch = require("node-fetch")

module.exports.run = async (bot, message, args) => {
 if (!args[0]) return message.reply('You did not enter a player name!');
 let Nick = args[0];
 let url = `https://api.vimeworld.ru/user/name/${Nick}`;
let response = await fetch(url);

let data = await response.json();
 if(!data){ return message.reply(`the Player "${Nick}" not found `);}
 for(var i = 0; i < data.length; i++) {
console.log(data[i])
 if(!profile[data[i].id]) {
 profile[data[i].id] = {
 username: data[i].username
 lvl: data[i].level
 likes: 0,
 dislikes: 0,
 rank: data[i].rank
};

 fs.writeFile('../database.json', JSON.stringify(profile), function(error){
 if(error) throw error;
}
};
};

 message.channel.send(`${Nick} was added to the database`)
};

module.exports.help = {
 name: "new"
}

However, nothing is written and no errors
April 7th 20 at 10:56
0 answer

Find more questions by tags JavaScriptNode.js