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;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace DiscordBot.Bot.Commands;
|
||||
/// <summary>
|
||||
/// The help command
|
||||
/// </summary>
|
||||
internal class Help: DBCommand
|
||||
internal class Help: IDbCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Command name
|
||||
@@ -32,7 +32,7 @@ internal class Help: DBCommand
|
||||
/// <summary>
|
||||
/// Check if the command require administrator to be executed
|
||||
/// </summary>
|
||||
public bool requireAdmin => false;
|
||||
public bool RequireAdmin => false;
|
||||
|
||||
/// <summary>
|
||||
/// The main body of the command
|
||||
@@ -58,7 +58,7 @@ internal class Help: DBCommand
|
||||
var normalCommands = "";
|
||||
|
||||
foreach (var cmd in PluginLoader.Commands)
|
||||
if (cmd.requireAdmin)
|
||||
if (cmd.RequireAdmin)
|
||||
adminCommands += cmd.Command + " ";
|
||||
else
|
||||
normalCommands += cmd.Command + " ";
|
||||
|
||||
@@ -9,11 +9,11 @@ using DiscordBotCore.Others;
|
||||
|
||||
namespace DiscordBot.Bot.Commands.SlashCommands;
|
||||
|
||||
public class Help: DBSlashCommand
|
||||
public class Help: IDbSlashCommand
|
||||
{
|
||||
public string Name => "help";
|
||||
public string Description => "This command allows you to check all loaded commands";
|
||||
public bool canUseDM => true;
|
||||
public bool CanUseDm => true;
|
||||
|
||||
public bool HasInteraction => false;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Help: DBSlashCommand
|
||||
return;
|
||||
}
|
||||
|
||||
embedBuilder.AddField("DM Usable:", slashCommand.canUseDM, true)
|
||||
embedBuilder.AddField("DM Usable:", slashCommand.CanUseDm, true)
|
||||
.WithDescription(slashCommand.Description);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user