More fixes to the new config. Module loader reworked
This commit is contained in:
@@ -49,7 +49,7 @@ namespace DiscordBot.Bot.Actions
|
||||
}
|
||||
|
||||
PluginInfo pluginInfo = new PluginInfo(args[^1], new(1, 0, 0), [], false, true, args.Contains("-enabled"));
|
||||
Application.CurrentApplication.Logger.Log("Adding plugin: " + args[^1]);
|
||||
Application.Logger.Log("Adding plugin: " + args[^1]);
|
||||
await Application.CurrentApplication.PluginManager.AppendPluginToDatabase(pluginInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Exit: ICommandAction
|
||||
{
|
||||
if (args is null || args.Length == 0)
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Exiting...", this, LogType.Warning);
|
||||
Application.Logger.Log("Exiting...", this, LogType.Warning);
|
||||
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class Exit: ICommandAction
|
||||
|
||||
case "-f":
|
||||
case "force":
|
||||
Application.CurrentApplication.Logger.Log("Exiting (FORCE)...", this, LogType.Warning);
|
||||
Application.Logger.Log("Exiting (FORCE)...", this, LogType.Warning);
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ internal static class PluginMethods
|
||||
|
||||
}catch(Exception ex)
|
||||
{
|
||||
Application.CurrentApplication.Logger.LogException(ex, typeof(PluginMethods), false);
|
||||
Application.Logger.LogException(ex, typeof(PluginMethods), false);
|
||||
} finally
|
||||
{
|
||||
await Application.CurrentApplication.InternalActionManager.Initialize();
|
||||
@@ -226,12 +226,12 @@ internal static class PluginMethods
|
||||
{
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Successfully loaded command : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
Application.Logger.Log("Successfully loaded command : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Failed to load command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
Application.Logger.Log("Failed to load command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
typeof(PluginMethods), LogType.Error
|
||||
);
|
||||
}
|
||||
@@ -242,11 +242,11 @@ internal static class PluginMethods
|
||||
{
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Successfully loaded event : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
Application.Logger.Log("Successfully loaded event : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Failed to load event : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
Application.Logger.Log("Failed to load event : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
typeof(PluginMethods), LogType.Error
|
||||
);
|
||||
}
|
||||
@@ -258,11 +258,11 @@ internal static class PluginMethods
|
||||
{
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Successfully loaded slash command : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
Application.Logger.Log("Successfully loaded slash command : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Failed to load slash command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
Application.Logger.Log("Failed to load slash command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
typeof(PluginMethods), LogType.Error
|
||||
);
|
||||
}
|
||||
@@ -274,11 +274,11 @@ internal static class PluginMethods
|
||||
{
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Successfully loaded action : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
Application.Logger.Log("Successfully loaded action : " + data.PluginName, LogType.Info, "\t\t > {Message}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Failed to load action : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
Application.Logger.Log("Failed to load action : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
typeof(PluginMethods), LogType.Error
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using DiscordBotCore;
|
||||
using DiscordBotCore.Interfaces;
|
||||
using DiscordBotCore.Interfaces.Modules;
|
||||
using DiscordBotCore.Modules;
|
||||
using DiscordBotCore.Others;
|
||||
using DiscordBotCore.Others.Actions;
|
||||
|
||||
@@ -45,15 +47,7 @@ namespace DiscordBot.Bot.Actions
|
||||
var modules = DiscordBotCore.Application.CurrentApplication.GetLoadedCoreModules();
|
||||
foreach (var module in modules)
|
||||
{
|
||||
Type moduleType = module.Key;
|
||||
List<object> moduleList = module.Value;
|
||||
|
||||
Console.WriteLine($"Module Type: {moduleType.Name}");
|
||||
|
||||
foreach (dynamic mod in moduleList)
|
||||
{
|
||||
Console.WriteLine($"Module: {mod.Name}");
|
||||
}
|
||||
Application.Logger.Log("Module: " + module.Key.ModuleName, this, LogType.Info);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,13 +128,7 @@ public class Plugin: ICommandAction
|
||||
case "load":
|
||||
if (pluginsLoaded)
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("Plugins already loaded", this, LogType.Warning);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Application.CurrentApplication.DiscordBotClient is null)
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log("DiscordBot is null", this, LogType.Warning);
|
||||
Application.Logger.Log("Plugins already loaded", this, LogType.Warning);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user