简体   繁体   English

TypeError:无法读取未定义的discord.js的属性“ add”

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

So i have a discord bot, and i have been forking some code and basically experminting. 所以我有一个不和谐的机器人,并且我一直在分叉一些代码并基本上在开发。 my synax is right however it says TypeError: Cannot read property 'add' of undefined when i try to make my discord.js bot add a role. 我的synax是正确的,但是它显示TypeError:当我尝试使discord.js机器人添加角色时,无法读取未定义的属性“ add”。

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)
})

Could someone please explain how to fix this as i am still noobish at this. 有人可以解释一下如何解决此问题,因为我对此仍然持怀疑态度。

找出问题所在,由于某些原因,角色ID无效,执行\\@role

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误:无法读取未定义的属性“添加”,Discord.JS - TypeError: Cannot read property 'add' of undefined, Discord.JS 类型错误:无法读取未定义 Discord.js javascript 的属性“添加” - TypeError: Cannot read property 'add' of undefined Discord.js javascript (Discord.js)TypeError:无法读取未定义的属性“添加” - (Discord.js) TypeError: Cannot read property 'add' of undefined discord.js错误TypeError:无法读取未定义的属性“ voiceChannel” - discord.js Error TypeError: Cannot read property 'voiceChannel' of undefined Discord.JS:TypeError:无法读取未定义的属性“角色” - Discord.JS:TypeError: Cannot read property 'roles' of undefined discord.js TypeError:无法读取未定义的属性“名称” - discord.js TypeError: Cannot read property 'name' of undefined “ TypeError:无法读取未定义的属性'push'” discord.js - “TypeError: Cannot read property 'push' of undefined” discord.js 类型错误:无法使用 Discord.js 读取未定义的属性“集” - TypeError: Cannot read property 'set' of undefined with Discord.js 类型错误:无法读取未定义的 Discord.js 错误的属性“get” - TypeError: Cannot read property 'get' of undefined Discord.js Error 类型错误:无法读取未定义的属性“成员” - Discord.JS - TypeError: Cannot read property 'members' of undefined - Discord.JS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM