我正在尝试创建一个不和谐的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");
});
fs.appendFile('log.txt', message.content, (err) => {
if (err) throw err;
});
除非需要多个日志文件,否则需要使用附加。