user_bw = message.content;
fs.writeFile("badwordlog.txt", user_bw, (err) => {
if (err)
console.log(err);
else {
console.log("badwordlog edited !");
}
});
I need to store all the badwords in a file . How to print the next word in the next line? I tried \n but it was not working.
The reason for this is that writeFile will replace the whole file. You can pass in a option flag which tells it to append new text to it. You may try:
user_bw = message.content;
fs.writeFile("badwordlog.txt", user_bw, { flag: "a+" }, (err) => {
if (err)
console.log(err);
else {
console.log("badwordlog edited !");
}
});