I wanted to make an eventHendler using a table. I did everything according to the guide on YouTube, but it doesn't work, there are no errors.
index.js
const { Client, GatewayIntentBits, Partials, Collection } = require("discord.js");
const { Guilds, GuildMembers, GuildMessages } = GatewayIntentBits;
const { User, Message, GuildMember, ThreadMember } = Partials;
const client = new Client({
intents: [Guilds, GuildMembers, GuildMessages],
partials: [User, Message, GuildMember, ThreadMember]
});
const { loadEvents } = require("./Handlers/eventHandler");
client.config = require("./config.json");
client.events = new Collection();
loadEvents(client);
client
.login(client.config.token)
.then( () => {
console.log(`client logged is as ${client.user.username}`);
client.user.setActivity(`with ${client.guilds.cache.size} guilds(s)`);
})
.catch((err) => console.log(err));
fileLoader.js
const { glob } = require("glob");
const { promisify } = require("util");
const proGlob = promisify(glob);
async function loadFiles(dirName){
const Files = await proGlob(`${process.cwd().replace(/\\/g, "/")}/${dirName}/**/*.js`);
Files.forEach((file) => delete require.cache[require.resolve(file)]);
return Files;
}
module.exports = { loadFiles }