最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Discord.JS V13 client.on messagecreate not firing - Stack Overflow

programmeradmin3浏览0评论

I've just recently finished upgrading my Discord.js bot to v13 and now the client.on(messageCreate) function doesn't fire? None of my code in it ever runs and I'm really confused as to why.

Before anybody asks, I have already set my intents.

const client = new Discord.Client({
  intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES ],
  partials: ['MESSAGE', 'CHANNEL', 'REACTION'], 
});

I have two functions, the client.on fires but the message doesn't

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('messageCreate', msg => {
  console.log(anything)
}

I've just recently finished upgrading my Discord.js bot to v13 and now the client.on(messageCreate) function doesn't fire? None of my code in it ever runs and I'm really confused as to why.

Before anybody asks, I have already set my intents.

const client = new Discord.Client({
  intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES ],
  partials: ['MESSAGE', 'CHANNEL', 'REACTION'], 
});

I have two functions, the client.on fires but the message doesn't

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('messageCreate', msg => {
  console.log(anything)
}
Share Improve this question edited Oct 15, 2021 at 5:56 Tony Patino asked Oct 14, 2021 at 19:37 Tony PatinoTony Patino 572 silver badges8 bronze badges 11
  • 1 Can you also post the code regarding this event? – node_modules Commented Oct 14, 2021 at 19:47
  • Please provide enough code so others can better understand or reproduce the problem. – Community Bot Commented Oct 15, 2021 at 1:42
  • 1 Ok i've added in the my events? – Tony Patino Commented Oct 15, 2021 at 5:59
  • Any errors or runs smoothly? – Lofn Commented Oct 15, 2021 at 13:32
  • It runs smoothly, just no outputs or anything – Tony Patino Commented Oct 15, 2021 at 16:21
 |  Show 6 more ments

1 Answer 1

Reset to default 5

Make sure you include GUILDS in your list of intents. Otherwise, the bot can only see messages that have been sent after the bot itself sent a message.

In my case, I needed to set these:

partials: ['MESSAGE', 'CHANNEL', 'REACTION']
intents: ['DIRECT_MESSAGES', 'DIRECT_MESSAGE_REACTIONS', 'GUILD_MESSAGES', 'GUILD_MESSAGE_REACTIONS', 'GUILDS']

but the particulars will vary by your use case.

发布评论

评论列表(0)

  1. 暂无评论