Fixed some null errors

This commit is contained in:
2024-04-09 20:40:18 +03:00
parent 0323c888b3
commit 123e8e90a1
5 changed files with 18 additions and 19 deletions

View File

@@ -2,9 +2,9 @@ namespace PluginManager.Loaders;
public class FileLoaderResult
{
public string PluginName { get; init; }
public string PluginName { get; private set; }
public string? ErrorMessage { get; init; }
public string ErrorMessage { get; private set; }
public FileLoaderResult(string pluginName, string errorMessage)
@@ -16,5 +16,6 @@ public class FileLoaderResult
public FileLoaderResult(string pluginName)
{
PluginName = pluginName;
ErrorMessage = string.Empty;
}
}

View File

@@ -9,14 +9,15 @@ public class PluginLoadResultData
public string? ErrorMessage { get; init; }
public bool IsSuccess { get; init; }
public object? Plugin { get; init; }
public object Plugin { get; init; }
public PluginLoadResultData(string pluginName, PluginType pluginType, bool isSuccess, string? errorMessage = null, object plugin = null)
public PluginLoadResultData(string pluginName, PluginType pluginType, bool isSuccess, string? errorMessage = null,
object? plugin = null)
{
PluginName = pluginName;
PluginType = pluginType;
IsSuccess = isSuccess;
ErrorMessage = errorMessage;
Plugin = plugin;
Plugin = plugin is null ? new() : plugin;
}
}

View File

@@ -3,7 +3,7 @@ using System.Threading.Tasks;
using Discord.WebSocket;
using PluginManager.Interfaces;
using PluginManager.Others;
using PluginManager.Updater.Plugins;
namespace PluginManager.Loaders;
@@ -21,9 +21,9 @@ public class PluginLoader
public EventLoaded? OnEventLoaded;
public SlashCommandLoaded? OnSlashCommandLoaded;
public static List<DBCommand>? Commands;
public static List<DBEvent>? Events;
public static List<DBSlashCommand>? SlashCommands;
public static List<DBCommand> Commands { get; private set; } = new List<DBCommand>();
public static List<DBEvent> Events { get; private set; } = new List<DBEvent>();
public static List<DBSlashCommand> SlashCommands { get; private set; } = new List<DBSlashCommand>();
public PluginLoader(DiscordSocketClient discordSocketClient)
{
@@ -32,10 +32,6 @@ public class PluginLoader
public async Task LoadPlugins()
{
Commands = new List<DBCommand>();
Events = new List<DBEvent>();
SlashCommands = new List<DBSlashCommand>();
Config.Logger.Log("Loading plugins...", typeof(PluginLoader));
var loader = new Loader(Config.AppSettings["PluginFolder"], "dll");