javascript - TypeError:无法读取未定义 discord.js 的属性“添加”
问题描述
所以我有一个不和谐的机器人,我一直在分叉一些代码并基本上进行实验。我的语法是正确的,但是它显示 TypeError: Cannot read property '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 由于某种原因无效,Doing\@role
成功了。
推荐阅读
- excel - 仅返回 2D 数组中的第一个元素 - ReDim 的使用不正确?
- php - 如果为空,MySQL 插入将日期设置为 30.11.-0001
- arrays - ObservedObject 列表更新
- c# - 为什么我的私人画廊无法从 Visual Studio 访问?
- angular - 有没有办法在指定的组件或文件中禁用 console.log?(Angular 8)
- amazon-web-services - 将 tf state 与现有 EC2 实例资源匹配
- session - 如何在根索引文件中获取 magento 客户会话值以切换商店视图
- java - 如何管理 Bison 生成的抽象语法树中的语法元素列表
- java - java.net.http.HttpClient 信任所有证书并关闭主机名验证
- c# - Visual Studio 中的 C# Web 表单