Discord.js JS Discord机器人找出有多少个角色

Discord.js JS Discord机器人找出有多少个角色,discord.js,Discord.js,我想知道我的机器人所在服务器上的角色总数。 我该怎么办?V11。提前谢谢 请尝试以下方法: message.guild.roles.forEach(role=>console.log(role.name,role.id)) Discord现在不支持v11。请更新到v12。在v12中,您可以通过获取帮会对象来获取帮会中的角色数,然后执行。roles.cache.size,将返回计数

我想知道我的机器人所在服务器上的角色总数。 我该怎么办?V11。提前谢谢

请尝试以下方法:

message.guild.roles.forEach(role=>console.log(role.name,role.id))

Discord现在不支持v11。请更新到v12。在v12中,您可以通过获取帮会对象来获取帮会中的角色数,然后执行
。roles.cache.size
,将返回计数