为什么 broadcastEval() 不是 return 公会的角色?

Why does broadcastEval() not return the roles of a guild?

这是我的代码:

await shardingManager.broadcastEval(`this.guilds.get('352896116812939264')`);

这就是上面的eval returns:

{ members: {},
  channels: {},
  roles: {},
  presences: {},
  deleted: false,
  available: true,
  id: '352896116812939264',
  name: 'LenoxBot™',
  ...}

我现在的问题是,为什么不 return 角色、频道、成员...


我什至尝试了以下方法,但也没有用

await shardingManager.broadcastEval(`this.guilds.get('352896116812939264').roles`);

(机器人有足够的权限查看所有角色等)

谢谢!

这里的问题是在稳定版本中 Guild#roles are not yet JSON serializable, for example due to cirucal references ( guild.roles.first().client ) 所以 node.js 只是 returns {}.

相关:https://github.com/discordjs/discord.js/issues/3144

On the development branch, all Discord.js objects are JSON serializable. Unfortunately, that change won't land until v12. ~ appellation

如前所述,您可以使用 discord.js v12,或者您需要自己序列化对象。