首页 > 解决方案 > 自动更新补货产品

问题描述

所以这是我的旧代码,它从文件中读取行,然后在库存中显示该文件有多少行。但是现在我希望我的机器人在从以下网站补货时自动更新:阿迪达斯欧盟、耐克欧盟和最高欧盟。那可能吗?

代码:

const Discord = require('discord.js');
const fs = require('fs');
module.exports.run = async (bot, message, args) => {

    let file1 = fs.readFileSync('spotify.txt').toString();
    let file2 = fs.readFileSync('netflix.txt').toString();
    let file3 = fs.readFileSync('disney+.txt').toString();
    lineCount1 = (file1.match(/\n/g) || '').length;
    lineCount2 = (file2.match(/\n/g) || '').length;
    lineCount3 = (file3.match(/\n/g) || '').length;
    var embed = new Discord.RichEmbed()
    .setColor("#c59c16")
    .addField(`This guild has the following service(s):`, `**SPOTIFY:**  ${lineCount1} \n **NETFLIX:** ${lineCount2} \n **DISNEY+:** ${lineCount3}`)
    message.channel.sendEmbed(embed);
}

module.exports.help = {
    name: "stock"
  }

标签: javascriptnode.jsdiscord

解决方案


推荐阅读