Ayustatus
Ayustatus
DIAdiscord.js - Imagine an app
Created by Ayustatus on 2/6/2024 in #djs-questions
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
4 replies