handler.js (915B)
1 const fs = require("fs"); 2 const cmds = []; 3 module.exports = async client => { 4 fs.readdirSync("./events").forEach(file => { 5 require(`${process.cwd()}/events/${file}`); 6 }); 7 fs.readdirSync("./client/commands").forEach(directory => { 8 if (directory !== "Owner") { 9 const commands = fs.readdirSync(`./client/commands/${directory}/`); 10 commands.map(value => { 11 const file = require(`${process.cwd()}/client/commands/${directory}/${value}`); 12 if (file.name) { 13 const properties = { directory, ...file }; 14 client.slashCommands.set(file.name, properties); 15 } 16 if (["MESSAGE", "USER"].includes(file.type)) delete file.description; 17 if (file.UserPerms) file.defaultPermission = false; 18 cmds.push(file); 19 }); 20 } 21 }); 22 client.on("ready", async () => { 23 await client.application.commands.set(cmds); 24 }); 25 };