Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  18] [ 5]  / answers: 1 / hits: 6213  / 3 Years ago, thu, october 14, 2021, 12:00:00

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)
}

More From » node.js

 Answers
11

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.


[#765] Thursday, October 7, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
domeniccolti

Total Points: 276
Total Questions: 98
Total Answers: 93

Location: India
Member since Fri, May 13, 2022
2 Years ago
domeniccolti questions
;