如何使用discord.js机器人在该行业中获得用户的角色

时间:2020-07-24 01:44:09

标签: node.js discord.js

好吧,所以我写了一个代码机器人,当我做!userinfo时,它显示了用户的信息

 Error: Could not find ffprobe executable, tried
 "C:\Users\amgad\Desktop\upload-videos\node_modules\@ffprobe-installer\win32-x64\ffprobe.exe"
 and "C:\Users\amgad\Desktop\upload-videos\node_modules\@ffprobe-installer\ffprobe\node_modules
\@ffprobe-installer\win32-x64\ffprobe.exe" 

所以我想做的是在其中添加一个显示Roles(角色)的字段:然后给出该人在该服务器中具有的角色。 我该怎么办?

1 个答案:

答案 0 :(得分:2)

您将无法从User对象访问公会成员的角色,必须使用GuildMember对象。您可能想要类似const member = message.mentions.members.first() || message.member之类的东西。在这里,您可以使用member.roles.cache访问角色(假设您使用的是v12)。

相关问题