TypeError: Cannot read property 'add' of undefined discord.js

TypeError: Cannot read property 'add' of undefined discord.js

所以我有一个 discord 机器人,我一直在分叉一些代码,基本上是在进行实验。我的 synax 是正确的,但是它说 TypeError: Cannot read 属性 'add' of undefined 当我试图让我的 discord.js 机器人添加角色时。

client.guilds.get(config.guild).member(message.author).role.add(config.role) // ensure this is a string in the config ("")
        .then(console.log(`TOKEN: ${message.author.token} :: Role ${config.role} added to member ${message.author.id}`))
        .catch(console.error)
})

谁能解释一下如何解决这个问题,因为我对此仍然很笨。

发现问题所在,角色 ID 由于某种原因无效,执行 \@role 成功了。