我在不同文件中存在常数问题:我必须将嵌入在另一个文件中,然后在主文件中调用,但是当我尝试这样做时,我解析了像Unexpected '.' in 'help.embed'
这样的错误,我尝试使用这些线程中建议的方法[1,2],但它们没有起作用:它继续给我解析错误。有人可以帮我吗?
PS:我不想使用HTML文件来调用脚本,我只想使用JS和JSON
这是我的代码(简化(:
// help.js
const Discord = require("discord.js");
var embed = new Discord.RichEmbed()
.setTitle("Title")
module.exports = Object.freeze({
embed: embed
});
// main.js
const help = require("./help.js")
client.on("ready", () =>{
client.channels.find("id",config.disaply_channel).send(help.embed); //Parse error
});
我发现,如果命令与嵌入的文件中,我应该使用message.channel.send({embed})
,因此我尝试发送help.{embed}
,但这给了我致命的错误。我解决了宣布导出embed: {embed}
而不是仅embed: embed
,然后在主文件中调用help.embed
。谢谢您的支持