const { glob } = require("glob"); const { promisify } = require("util"); const { Client } = require("discord.js"); const globPromise = promisify(glob); /** * @param {Client} client */ module.exports = async (client) => { // events handler const eventFiles = await globPromise(`${process.cwd()}/events/*.js`); eventFiles.map((value) => require(value)); // slash commands handler const slashCommands = await globPromise( `${process.cwd()}/SlashCommands/*/*.js` ); const arrayOfSlashCommands = []; slashCommands.map((value) => { const file = require(value); if (!file?.name) return; client.slashCommands.set(file.name, file); if (["MESSAGE", "USER"].includes(file.type)) delete file.description; arrayOfSlashCommands.push(file); }); client.on("ready", async () => { //for single guild await client.guilds.cache .get("882813938947985408") .commands.set(arrayOfSlashCommands); // for global // await client.application.commands.set(arrayOfSlashCommands); }); };