I need help making adjustments to my code in order for people on Discord to write into my text file without creating an extra blank line. Currently, my code looks like this:
client.on("message", msg => {
const triggerWords = ['ff'];
const fs = require('fs');
const args = msg.content.trim().split(/ +/g);
triggerWords.forEach((word) => {
if(msg.content.includes(word)) {
const con = args[1];
const content = ` ${con}\n`
fs.appendFile('textart.txt',content,err => {
if(err) {
console.error(err)
return
}
})
}
})
});
My desired output in the txt file is as follows:
1 joke1
2 joke2
3 joke3
However, I am currently experiencing an issue where an extra blank line is added at the end, resulting in the following output:
1 joke1
2 joke2
3 joke3
4
How can I modify the code to prevent the creation of this extra blank line? Any assistance would be greatly appreciated! Have a wonderful day!