将消息记录到文本文件中

问题描述 投票:-1回答:1

我正在尝试创建一个不和谐的bot,该bot读取最后一条消息,如果它包含custom fields:,则返回一条消息。我想将整个邮件记录到txt文件中。我该怎么办?

const Discord = require('discord.js');
const client = new Discord.Client();
const token = 'mytoken'; // Token goes here.

client.login(token); // login the bot with your token.

client.on('message', message => {


    if(message.content.toLowerCase().includes('custom field:'))
        message.channel.send("Custom field detected");


});

javascript node.js discord discord.js
1个回答
0
投票
fs.appendFile('log.txt', message.content, (err) => {
  if (err) throw err;
});

除非需要多个日志文件,否则需要使用附加。

© www.soinside.com 2019 - 2024. All rights reserved.