0

When someone use a command of my bot, like: /ban Player123 ReasonXYZ. I want the User who got banned with the reason and the user who banned Player123 is in a file named "banlist.json"

Sorry for bad english

const banlogmsg = message.author.tag + '  |  ' + (banreason) + ' |  ' (bannedplayer)

fs.writeFileSync('./banlog.json', JSON.stringify(banlogmsg))
Simon
  • 1
  • 2
  • 3
    Does this answer your question? [Write / add data in JSON file using Node.js](https://stackoverflow.com/a/36856787/15446076) – Tetie Jan 25 '23 at 17:40

1 Answers1

0

I will show you how to actually send the file in a message. It's also better to use Buffer (integrated into nodejs) instead of fs.

let channel = message.channel;
let banlogmsg = message.author.tag + '  |  ' + (banreason) + ' |  ' (bannedplayer);

channel.send({files:[{attachment:Buffer.from(JSON.stringify(banlogmsg)),name:`banlog.json`}]});

I hope that answers your question.

yacine
  • 91
  • 5