質問するログイン新規登録

回答編集履歴

2

表現の修正

2021/10/21 10:59

投稿

fj68
fj68

スコア752

answer CHANGED
@@ -17,15 +17,20 @@
17
17
 
18
18
  ## 追記
19
19
 
20
- メッセージが作成されたときにそのメッセージの`author`自分ならリアクションをつければOKではないでしょうか。
20
+ メッセージが作成されたときにそのメッセージがbotのものならリアクションをつければOKではないでしょうか。
21
21
 
22
22
  ```js
23
23
  client.on("messageCreate", async message => {
24
- if (message.author.id === client.user.id) {
24
+ if (message.author.bot) {
25
25
  message.react('????');
26
26
  return;
27
27
  }
28
- if (message.author.bot) return;
29
28
  /* ...その他いろいろやる */
30
29
  }
30
+ ```
31
+
32
+ 自分のメッセージだけにつけたいなら以下です。
33
+
34
+ ```js
35
+ if (message.author.id === client.user.id) { /* ... */ }
31
36
  ```

1

コード追記

2021/10/21 10:59

投稿

fj68
fj68

スコア752

answer CHANGED
@@ -13,4 +13,19 @@
13
13
  message.react(message.guild.emojis.cache.get('123456789012345678'))
14
14
  .then(console.log)
15
15
  .catch(console.error);
16
+ ```
17
+
18
+ ## 追記
19
+
20
+ メッセージが作成されたときにそのメッセージの`author`が自分ならリアクションをつければOKではないでしょうか。
21
+
22
+ ```js
23
+ client.on("messageCreate", async message => {
24
+ if (message.author.id === client.user.id) {
25
+ message.react('????');
26
+ return;
27
+ }
28
+ if (message.author.bot) return;
29
+ /* ...その他いろいろやる */
30
+ }
16
31
  ```