messageCreate not triggering

node version: 17.0.1 intents:
const intentArray = Object.keys(
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.MessageContent);
const bot = new Client({
intents: intentArray,
partials: ['GUILD_MESSAGES', 'MESSAGE', 'CHANNEL', 'REACTION']
});
if (auth.branch == "dev") {
// bot.login(test_token);
} else if (auth.branch == "master") {
bot.login(auth.token);
}
const intentArray = Object.keys(
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.MessageContent);
const bot = new Client({
intents: intentArray,
partials: ['GUILD_MESSAGES', 'MESSAGE', 'CHANNEL', 'REACTION']
});
if (auth.branch == "dev") {
// bot.login(test_token);
} else if (auth.branch == "master") {
bot.login(auth.token);
}
event handling:
const eventFiles = fs.readdirSync('./src/events').filter(file => file.endsWith('.js'));
for (const name of eventFiles) {
const event = require(`./events/${name}`);

if (event.once){
bot.once(event.name, (...args) => {
event.execute(...args);
});
}else{
bot.on(event.name, (...args) => {
console.log(`event ${event.name} is triggered`)
event.execute(...args);
});
}
console.log("event: " + event.name + " has been loaded");
}
const eventFiles = fs.readdirSync('./src/events').filter(file => file.endsWith('.js'));
for (const name of eventFiles) {
const event = require(`./events/${name}`);

if (event.once){
bot.once(event.name, (...args) => {
event.execute(...args);
});
}else{
bot.on(event.name, (...args) => {
console.log(`event ${event.name} is triggered`)
event.execute(...args);
});
}
console.log("event: " + event.name + " has been loaded");
}
.src/events/messageCreate.js:
const { Events } = require('discord.js');
module.exports = {
name: Events.MessageCreate,
async execute(message) {
console.log("message is created")
console.log(`messageCreate: ${message}`);

},
};
const { Events } = require('discord.js');
module.exports = {
name: Events.MessageCreate,
async execute(message) {
console.log("message is created")
console.log(`messageCreate: ${message}`);

},
};
console: $ node src/bot.js command: messagehistory has been loaded command: status has been loaded event: interactionCreate has been loaded event: messageCreate has been loaded event: messageDelete has been loaded event: ready has been loaded ... Ready! Logged in as BOTNAME#XXXX logfile: [WS => Shard 0] Shard will not receive any more guild packets. Unavailable guild count: 1 [WS => Shard 0] First heartbeat sent, starting to beat every 41250ms So the only thing that I can see would be the Unavailable Guild count:1 but the bot still works with both commands,ready and interactionCreate events are triggered
3 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
space
space10mo ago
You intents array is empty. You want to just use a boring array instead of the adventerous Object.keys thing you got there. Fixing that should give you the messages you desire.
Ayustatus
AyustatusOP10mo ago
it did...thank you, dont even remember why I did it that way, prob some example I saw way back when and then just copied to newer bots and this was the first time it caused an issue.
Want results from more Discord servers?
Add your server