回答編集履歴

4

コード修正

2021/10/26 12:55

投稿

fj68
fj68

スコア752

test CHANGED
@@ -30,17 +30,23 @@
30
30
 
31
31
 
32
32
 
33
- const collected = await message.awaitReactions({ filter });
33
+ message.awaitReactions({ filter })
34
34
 
35
- // collectedはCollection<string, MessageReaction>
35
+ .then(collected => {
36
36
 
37
- // reaction.usersReactionUserManager
37
+ // collectedはCollection<string, MessageReaction>
38
38
 
39
- // reaction.users.cacheCollection<Snowflake, User>
39
+ // reaction.usersはReactionUserManager
40
40
 
41
- // collected.map(...)だけだと[[User, User, ...], [User, ...], ...]となるためflattenする
41
+ // reaction.users.cacheはCollection<Snowflake, User>
42
42
 
43
+ // collected.map(...)だけだと[[User, User, ...], [User, ...], ...]となるためflattenする
44
+
43
- const users = collected.map(reaction => reaction.users.cache.values()).flat();
45
+ const users = collected.map(reaction => reaction.users.cache.values()).flat();
46
+
47
+ /* ... */
48
+
49
+ });
44
50
 
45
51
  ```
46
52
 

3

リンクをまとめた

2021/10/26 12:55

投稿

fj68
fj68

スコア752

test CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
 
4
4
 
5
- [Reactions | Discord.js Guide](https://discordjs.guide/popular-topics/reactions.html#awaiting-reactions)
5
+ - [Reactions | Discord.js Guide](https://discordjs.guide/popular-topics/reactions.html#awaiting-reactions)
6
+
7
+ - [Message.awaitReactions - discord.js](https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=awaitReactions)
6
8
 
7
9
 
8
10
 
@@ -48,8 +50,4 @@
48
50
 
49
51
 
50
52
 
51
- [Message.awaitReactions - discord.js](https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=awaitReactions)
52
-
53
-
54
-
55
53
  ご参考まで。

2

コード修正

2021/10/26 12:53

投稿

fj68
fj68

スコア752

test CHANGED
@@ -28,23 +28,17 @@
28
28
 
29
29
 
30
30
 
31
- message.awaitReactions({ filter })
31
+ const collected = await message.awaitReactions({ filter });
32
32
 
33
- .then(collected => {
33
+ // collectedはCollection<string, MessageReaction>
34
34
 
35
- // collectedCollection<string, MessageReaction>
35
+ // reaction.usersReactionUserManager
36
36
 
37
- // reaction.usersはReactionUserManager
37
+ // reaction.users.cacheCollection<Snowflake, User>
38
38
 
39
- // reaction.users.cacheはCollection<Snowflake, User>
39
+ // collected.map(...)だけだと[[User, User, ...], [User, ...], ...]となるためflattenする
40
40
 
41
- // collected.map(...)だけだと[[User, User, ...], [User, ...], ...]となるためflattenする
42
-
43
- const users = collected.map(reaction => reaction.users.cache.values()).flat();
41
+ const users = collected.map(reaction => reaction.users.cache.values()).flat();
44
-
45
- })
46
-
47
- .catch(e => /* エラー処理 */);
48
42
 
49
43
  ```
50
44
 

1

Message取得方法について追記

2021/10/26 12:52

投稿

fj68
fj68

スコア752

test CHANGED
@@ -10,7 +10,15 @@
10
10
 
11
11
 
12
12
 
13
+ `Message`自体は`Channel.send()`の返値を使えばいいでしょう。
14
+
15
+
16
+
13
17
  ```js
18
+
19
+ const message = channel.send('メッセージ');
20
+
21
+
14
22
 
15
23
  const filter = (reaction, _user) => {
16
24