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

回答編集履歴

2

最初のガード節の挙動が逆だったので修正

2021/11/28 18:17

投稿

miyabi-sun
miyabi-sun

スコア21459

answer CHANGED
@@ -50,7 +50,7 @@
50
50
  };
51
51
 
52
52
  client.on("message", async message => {
53
- if (message.content.startsWith(prefix)) return;
53
+ if (!message.content.startsWith(prefix)) return;
54
54
  const [command, ...args] = message.content.replace(prefix, "").split(" ");
55
55
 
56
56
  // 上記のcommandsで定義されているキーで無ければ

1

channelじゃなくてcontentだった

2021/11/28 18:17

投稿

miyabi-sun
miyabi-sun

スコア21459

answer CHANGED
@@ -50,7 +50,7 @@
50
50
  };
51
51
 
52
52
  client.on("message", async message => {
53
- if (message.channel.startsWith(prefix)) return;
53
+ if (message.content.startsWith(prefix)) return;
54
54
  const [command, ...args] = message.content.replace(prefix, "").split(" ");
55
55
 
56
56
  // 上記のcommandsで定義されているキーで無ければ