【发布时间】:2017-11-29 04:53:02
【问题描述】:
我在不同文件中遇到常量问题:我必须将嵌入存储在另一个文件中,然后在主文件中调用它,但是当我尝试这样做时,它会给我解析错误,例如 Unexpected '.' in 'help.embed' I尝试使用这些线程 [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
});
【问题讨论】:
-
您确定
help对象可以正常通过吗?将embed属性记录到控制台时,您看到了吗? -
试试
.send({help.embed}) -
我记录了帮助对象,我清楚地看到了嵌入属性,类型为 RichEmbed。我也尝试只记录 help.embed ,它是一个普通对象。但是当我尝试发送它时,它返回“无法发送空消息”或类似的东西
标签: javascript discord discord.js