UNPKG

myteams-api

Version:

An MyTeams Module to use discord.js and Twitch API easily

39 lines 1.56 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RegisterCommand = void 0; const fs_1 = __importDefault(require("fs")); const chalk_1 = __importDefault(require("chalk")); const Error_1 = require("../Utils/Error"); function RegisterCommand(path, client, log, Collection) { if (!path) throw new Error_1.MyTeamsError("A path its required."); if (!client) throw new Error_1.MyTeamsError("Please provide a Client"); if (!Collection) throw new Error_1.MyTeamsError("Please provide a Discord.Collection"); fs_1.default.readdir(path, (err, folders) => { if (err) throw err; for (const folder of folders) { fs_1.default.readdir(`${path}/${folder}`, (err, files) => { if (err) throw err; for (const file of files) { const command = require(`${path}/${folder}/${file}`); Collection.set(command.name, command); if (log) { console.log(chalk_1.default.green(`${command.name} loaded successfully.`)); } else { return; } } }); } }); } exports.RegisterCommand = RegisterCommand; //# sourceMappingURL=CommandHandler.js.map