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