/// <summary> /// Run init on all modules and create ConfigFiles. /// </summary> /// <returns></returns> internal async Task InitializeModules() { for (int i = 0; i < LoadedModules.Count; i++) { YModule module = LoadedModules[i]; RequiredModule requiredModule = module.GetType().GetCustomAttribute <RequiredModule>(); if (requiredModule != null) { for (int a = 0; a < requiredModule.Types.Count; a++) { Type type = requiredModule.Types[a]; if (!LoadedModules.Exists(m => m.GetType() == type)) { await Bot.LoggingManager.LogMessage(LogLevel.Warning, $"Unable to initalize module {module.Name} it requires {type.Name} wich is not loaded.", "ModuleManager").ConfigureAwait(false); return; } } } module.SetContext(new MethodContext(Client.Guilds.FirstOrDefault(), null, null)); await module.InitModule().ConfigureAwait(false); } for (int i = 0; i < LoadedModules.Count; i++) { YModule module = LoadedModules[i]; await module.ModuleDone(); } }