LoginSignup
6
0

More than 1 year has passed since last update.

discord.js v14でmessageCreateイベントが思い通りに動いてくれなくて困ってる人へ

Posted at

前提

Discord Developer Portalの Privileged Gateway Intents 設定にて以下の設定がONになっている

  • MESSAGE CONTENT INTENT

なぜ動かないのか

v14から追加された新しいインテント GatewayIntentBits.MessageContent が付与されてないから動かない

const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]});

client.on('ready', () => {
  console.log("Client have been launched.");
});

client.on('messageCreate', async (message) => {
  if(message.content === "!ping") {
        message.reply("Pong!")
  }
});

これ、ドキュメントにすら書いてない(または書いてあるけどどっかに埋もれてる)

しかも、これがないとnullではなく空文字列が返ってくるという始末

参考

message.content doesn't have any value in Discord.js v14 - stackoverflow

6
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
0