所以我制作了一个不和谐的机器人,将他托管在GitHub和Heroku上,我用“文件系统”做了一些命令,这些命令在文件(ami.txt)中写入了用户ID在本地运行了/ ami命令,但是当我尝试使用GitHub和Heroku无法100%运行的命令时,当我向我的机器人发送命令“在我的ID和我的用户名不一致的文件中写入”时,但是他没有将这些数据写到GitHub文件中,所以当我重新启动bot时,所有的重置...
这是我的代码:
bot.on('message', msg => {
if(msg.content === PREFIX + "ami") {
var array2 = fs.readFileSync('./ami.txt').toString().split("\n");
if (array2.includes(msg.author.id)) {
msg.channel.send('We are already friends...');
}
else if(!array2.includes(msg.author.id)) {
msg.channel.send('Hey, new friend');
fs.appendFileSync('./ami.txt', ` \n`);
fs.appendFileSync('./ami.txt', `${msg.author.username}#${msg.author.discriminator}\n`);
fs.appendFileSync('./ami.txt', `${msg.author.id}\n`);
fs.close
}
}
});
bot.on('message', msg => {
if(msg.content === PREFIX + "ami-list") {
var array2 = fs.readFileSync('./ami.txt').toString().split("\n");
msg.channel.send(array2)
fs.close
}
})