首页 > 解决方案 > 我如何从收藏中获得第二个成员

问题描述

我有这个收藏:

  Collection {
  '200641654165165' => ClientUser {
  id: '200641654165165',
  username: 'test',
  discriminator: '4905',
  avatar: 'r32rfk324r5aspp;d',
  bot: true,
  lastMessageID: '450334234326660373',
  lastMessage:
   Message {
     channel: [TextChannel],
     id: '45035325246660373',
     type: 'DEFAULT',
     content: '',
     author: [Circular],
     member: [GuildMember],
     pinned: false,
     tts: false,
     nonce: null,
     system: false,
     embeds: [Array],
     attachments: Collection {},
     createdTimestamp: 152723434238,
     editedTimestamp: null,
     reactions: Collection {},
     mentions: [MessageMentions],
     webhookID: null,
     hit: null,
     _edits: [] },
  verified: true,
  email: null,
  localPresence: { status: 'online', game: [Object], afk: false, since: 0 },
  _typing: Map {},
  friends: Collection {},
  blocked: Collection {},
  notes: Collection {},
  premium: null,
  mfaEnabled: true,
  mobile: null,
  settings: ClientUserSettings { user: [Circular] },
  guildSettings: Collection {} },
  '204651434234236752' => User {
  id: '204651434234236752',
  username: 'me',
  discriminator: '4212',
  avatar: '9574776gfv3f3c01facc41a01d26',
  bot: false,
  lastMessageID: '45036434494844427',
  lastMessage:
   Message {
     channel: [TextChannel],
     id: '45036953244844427',
     type: 'DEFAULT',
     content: '.c',
     author: [Circular],
     member: [GuildMember],
     pinned: false,
     tts: false,
     nonce: '450369532530174208',
     system: false,
     embeds: [],
     attachments: Collection {},
     createdTimestamp: 1523246950554,
     editedTimestamp: null,
     reactions: Collection {},
     mentions: [MessageMentions],
     webhookID: null,
     hit: null,
     _edits: [] } } }

我用这个得到了

const reactions = await msg.awaitReactions(reaction => reaction.emoji.name === join, {time: 3000})
const user = reactions.get(join).users

而且我不知道如何从这个集合中获得第二个成员。

标签: javascriptnode.jsdiscorddiscord.js

解决方案


找到解决方案。

用“const user =reactions.get(join).users.first(2)[1]”替换“const user = reaction.get(join).users”


推荐阅读