NodeJS-DiscordJS : Handler read my event but doesn't work

Viewed 21

My handler detects my new js files but does not execute them. However, if I rename one of the new files with the name of one of the old ones without touching the code, it works. Can you help me? Thanks ! My handler code for events :

const loadEvents = (dir = "./events/") => {
  readdirSync(dir).forEach(dirs => {
    const events = readdirSync(`${dir}/${dirs}/`).filter(files => files.endsWith(".js"));

    for (const event of events) {
      const evt = require(`${dir}/${dirs}/${event}`);
       const evtName = event.split(".")[0];
      bot.on(evtName, evt.bind(null, bot));
      console.log(`Evènement chargé : ${evtName}`);
    };
  });
};
0 Answers
Related