【发布时间】:2019-11-06 15:50:36
【问题描述】:
我有这样的事情......
const channel = await message.guild.createChannel("channel-name", {
type: 'text',
permissionOverwrites: [{
id: message.guild.id,
deny: ['SEND_MESSAGES','SEND_TTS_MESSAGES']
}]
}).then(channel => {
channel.setTopic("Topic")
});
const loc = "./data/test.json";
let data = JSON.parse(fs.readFileSync(loc));
data = {
channel.id
};
fs.writeFileSync(loc, JSON.stringify(data, null, 2), (err) => {
if(err) console.log(err)
});
我想将频道 ID“频道名称”保存在 json 文件中,但出现此错误
(node:16060) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
语言:discord.js、node.js
【问题讨论】:
-
错误在哪一行?
标签: javascript