[英]Discord bot: removing a specific role from a specific user
Let me start of saying - I am a total newb to javascript, as well as discord with javascript.让我开始说 - 我是 javascript 以及 discord 和 javascript 的新手。
With that said, I have a string that was determined elsewhere in the code, Username.话虽如此,我有一个在代码中其他地方确定的字符串,用户名。 This string is literally the discord username (IE username#1234) for a specific member of the server this bot is running in. I am trying to remove a role from this user, via the line:
该字符串实际上是运行此机器人的服务器的特定成员的 discord 用户名(IE 用户名#1234)。我正在尝试通过以下行从该用户中删除角色:
message.guild.Username.roles.remove('roleid');
instead, it returns the error: TypeError: Cannot read property 'roles' of undefined
相反,它返回错误:
TypeError: Cannot read property 'roles' of undefined
Am I not able to use a string in this manner?我不能以这种方式使用字符串吗? If not, how can I remove this person's role another way?
如果没有,我该如何以另一种方式删除此人的角色? Any help appreciated!
任何帮助表示赞赏!
`message.guild.Username.roles.remove('roleid');`
Instead you have to type: const Username = 'username#1234';
相反,您必须输入:
const Username = 'username#1234';
message.guild.(Username).removeRole('roleid')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.