Example #1
0
			files.forEach(function (file) {
				let absFile = Path.resolve(path, file + '/botmodule.json');
				if (FileSystem.existsSync(absFile) && FileSystem.statSync(absFile).isFile()) {
					try {
						let conf = require(absFile);
						if (conf.id && this.config.loadmodules[conf.id] !== false) {
							let mod = new BotMod(Path.resolve(path, file), conf, this);
							this.modules[mod.id] = mod;
							this.parser.addCommands(mod.commands);
							this.multilang.addLangFiles(mod.langfiles, Path.resolve(path, file));
							console.log('NEW MODULE: ' + mod.name);
						} else if (!this.modules[conf.id]) {
							this.modules[conf.id] = {
								id: conf.id,
								name: conf.name,
								description: conf.description,
								commands: {},
								system: null,
								enabled: false,
							};
						}
					} catch (err) {
						console.log('Error: Cannot load module "' + file + '" - ' + err.message + '\n' + err.stack);
					}
				}
			}.bind(this));
Example #2
0
			files.forEach(function (file) {
				let absFile = Path.resolve(path, file + '/botmodule.json');
				if (FileSystem.existsSync(absFile) && FileSystem.statSync(absFile).isFile()) {
					try {
						uncacheTree(absFile);
						let conf = require(absFile);
						if (conf.commands) {
							for (let i = 0; i < conf.commands.length; i++) {
								let cmdFile = Path.resolve(path, file, conf.commands[i]);
								try {
									uncacheTree(cmdFile);
								} catch (e) {}
								let commands = require(cmdFile);
								this.parser.addCommands(commands);
							}
						}
					} catch (err) {
						console.log('Error: Cannot load module "' + file + '" - ' + err.message);
					}
				}
			}.bind(this));