我正在尝试从Nodejs(discord.js)中访问消息
{
"627832600865800222": { //guild id
"348832732647784460": { // author id
"message": "hii hello"
}
}
}
let author_id = message.author.id
let guild_id = message.guild.id
let out = msg [guild_id].author_id.message
console.log(out)
预期输出:hii
但结果输出:未定义 guild_id之后,输出未定义
答案 0 :(得分:-1)
更改let out = msg [guild_id].author_id.message
到let out = msg[guild_id][author_id].message
属性访问者的MDN文档参考:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors