Fixed Startup error after downloading the logger

This commit is contained in:
2024-08-29 20:00:25 +03:00
parent 1c002edc6d
commit a23da51c08
5 changed files with 26 additions and 18 deletions

View File

@@ -87,6 +87,10 @@ namespace DiscordBotCore
{
moduleRequirementsSolver ??= requirement => CurrentApplication.ModuleManager.SolveRequirementIssues(requirement);
await moduleRequirementsSolver(requirements);
await CurrentApplication.ModuleManager.LoadModules();
Logger._LoggerModule = CurrentApplication.ModuleManager.GetLoadedModuleWithTag(ModuleType.Logger);
}
@@ -142,7 +146,7 @@ namespace DiscordBotCore
/// </summary>
public static class Logger
{
private static readonly LoadedModule _LoggerModule = CurrentApplication.ModuleManager.GetLoadedModuleWithTag(ModuleType.Logger);
internal static LoadedModule _LoggerModule = null!; // initial is null, will be populated when the application will load all modules !!
public static async void LogException(Exception ex, object sender, bool fullStackTrace = false)
{
await CurrentApplication.ModuleManager.InvokeMethod(_LoggerModule.Value, _LoggerModule.Value.MethodMapping["BaseLogException"], [ex, sender, fullStackTrace]);

View File

@@ -181,6 +181,8 @@ namespace DiscordBotCore.Modules
internal async Task LoadModules()
{
Modules.Clear();
string moduleConfigPath = Application.CurrentApplication.ApplicationEnvironmentVariables
.Get<string>("ModuleConfig", _BaseModuleConfig);