Fixed some null errors
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<StartupObject />
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<IsPublishable>True</IsPublishable>
|
||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
||||
<AssemblyVersion>1.0.3.2</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>none</DebugType>
|
||||
|
||||
@@ -6,6 +6,7 @@ using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using PluginManager.Interfaces;
|
||||
using PluginManager.Loaders;
|
||||
using PluginManager.Online;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Others.Permissions;
|
||||
|
||||
@@ -45,10 +46,10 @@ internal class CommandHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
var plugin = PluginLoader.SlashCommands!.FirstOrDefault(p => p.Name == arg.Data.Name);
|
||||
var plugin = PluginLoader.SlashCommands.FirstOrDefault(p => p.Name == arg.Data.Name);
|
||||
|
||||
if (plugin is null)
|
||||
throw new Exception("Failed to run command. !");
|
||||
throw new Exception("Failed to run command !");
|
||||
|
||||
|
||||
if (arg.Channel is SocketDMChannel)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user