Command Handler

You can use the command handler if you want the main file to be clean of bot commands.

const fs = require("fs");
const path = "./pathToDir/";

var reader = fs.readdirSync(path).filter((file) => file.endsWith(".js"));
for (const file of reader) {
  const command = require(path + file);
  bot.command({
    name: command.name,
    code: command.code,
  });
}

Last updated

Was this helpful?