TypeError:无法读取未定义的discord.js的属性"add" [英] TypeError: Cannot read property 'add' of undefined discord.js

查看:45
本文介绍了TypeError:无法读取未定义的discord.js的属性"add"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个不和谐的机器人,并且我一直在分叉一些代码并基本上在驱赶.我的synax是正确的,但是它显示TypeError:当我尝试使discord.js机器人添加角色时,无法读取未定义的属性"add".

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.

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 可以解决问题.

Found out what was wrong, the Role ID Was invalid for some reason, Doing \@role did the trick.

这篇关于TypeError:无法读取未定义的discord.js的属性"add"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆