【发布时间】:2020-05-17 08:18:35
【问题描述】:
我正在尝试获取对消息做出反应的每个用户的用户 ID 或等效项。我的代码看起来像这样,在我收到的输出中,我可以看到用户 ID。但我不知道如何抓住它们。有任何想法吗?我已经尝试过诸如 collection.users 之类的东西,但似乎没有任何效果。
这是我的代码,
const sumSeconds = 5;
const filter = reaction => {
return ['????'].includes(reaction.emoji.name);
}
message.channel.send("React with ???? for a chance to win").then( message => {
message.react("????");
message.awaitReactions(filter,{max:50,time:sumSeconds*1000}).then(collection => {
console.log(collection);
}).catch();
}).catch();
这是我打印时集合输出的内容
Collection [Map] {
'????' => MessageReaction {
message: Message {
channel: [TextChannel],
deleted: false,
id: '672835948395216429',
type: 'DEFAULT',
content: 'React with ???? for a chance to win',
author: [ClientUser],
member: [GuildMember],
pinned: false,
tts: false,
nonce: null,
system: false,
embeds: [],
attachments: Collection [Map] {},
createdTimestamp: 1580486989843,
editedTimestamp: null,
reactions: [Collection [Map]],
mentions: [MessageMentions],
webhookID: null,
hit: null,
_edits: []
},
me: true,
count: 2,
users: Collection [Map] {
'671732735845016837' => [ClientUser],
'181250039684617312' => [User]
},
_emoji: ReactionEmoji { reaction: [Circular], name: '????', id: null }
}
}
我要提取的是这部分
users: Collection [Map] {
'671732735845016837' => [ClientUser],
'181250039684617312' => [User]
}
请帮帮忙:
【问题讨论】:
标签: node.js discord discord.js