Fixed some null errors
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<StartupObject />
|
<StartupObject />
|
||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<IsPublishable>True</IsPublishable>
|
<IsPublishable>True</IsPublishable>
|
||||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
<AssemblyVersion>1.0.3.2</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Discord.Commands;
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
using PluginManager.Loaders;
|
using PluginManager.Loaders;
|
||||||
|
using PluginManager.Online;
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
using PluginManager.Others.Permissions;
|
using PluginManager.Others.Permissions;
|
||||||
|
|
||||||
@@ -13,9 +14,9 @@ namespace PluginManager.Bot;
|
|||||||
|
|
||||||
internal class CommandHandler
|
internal class CommandHandler
|
||||||
{
|
{
|
||||||
private readonly string _botPrefix;
|
private readonly string _botPrefix;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly CommandService _commandService;
|
private readonly CommandService _commandService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command handler constructor
|
/// Command handler constructor
|
||||||
@@ -45,10 +46,10 @@ internal class CommandHandler
|
|||||||
{
|
{
|
||||||
try
|
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)
|
if (plugin is null)
|
||||||
throw new Exception("Failed to run command. !");
|
throw new Exception("Failed to run command !");
|
||||||
|
|
||||||
|
|
||||||
if (arg.Channel is SocketDMChannel)
|
if (arg.Channel is SocketDMChannel)
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ namespace PluginManager.Loaders;
|
|||||||
|
|
||||||
public class FileLoaderResult
|
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)
|
public FileLoaderResult(string pluginName, string errorMessage)
|
||||||
@@ -16,5 +16,6 @@ public class FileLoaderResult
|
|||||||
public FileLoaderResult(string pluginName)
|
public FileLoaderResult(string pluginName)
|
||||||
{
|
{
|
||||||
PluginName = pluginName;
|
PluginName = pluginName;
|
||||||
|
ErrorMessage = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,15 @@ public class PluginLoadResultData
|
|||||||
public string? ErrorMessage { get; init; }
|
public string? ErrorMessage { get; init; }
|
||||||
public bool IsSuccess { 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;
|
PluginName = pluginName;
|
||||||
PluginType = pluginType;
|
PluginType = pluginType;
|
||||||
IsSuccess = isSuccess;
|
IsSuccess = isSuccess;
|
||||||
ErrorMessage = errorMessage;
|
ErrorMessage = errorMessage;
|
||||||
Plugin = plugin;
|
Plugin = plugin is null ? new() : plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
using PluginManager.Updater.Plugins;
|
|
||||||
|
|
||||||
namespace PluginManager.Loaders;
|
namespace PluginManager.Loaders;
|
||||||
|
|
||||||
@@ -21,9 +21,9 @@ public class PluginLoader
|
|||||||
public EventLoaded? OnEventLoaded;
|
public EventLoaded? OnEventLoaded;
|
||||||
public SlashCommandLoaded? OnSlashCommandLoaded;
|
public SlashCommandLoaded? OnSlashCommandLoaded;
|
||||||
|
|
||||||
public static List<DBCommand>? Commands;
|
public static List<DBCommand> Commands { get; private set; } = new List<DBCommand>();
|
||||||
public static List<DBEvent>? Events;
|
public static List<DBEvent> Events { get; private set; } = new List<DBEvent>();
|
||||||
public static List<DBSlashCommand>? SlashCommands;
|
public static List<DBSlashCommand> SlashCommands { get; private set; } = new List<DBSlashCommand>();
|
||||||
|
|
||||||
public PluginLoader(DiscordSocketClient discordSocketClient)
|
public PluginLoader(DiscordSocketClient discordSocketClient)
|
||||||
{
|
{
|
||||||
@@ -32,10 +32,6 @@ public class PluginLoader
|
|||||||
|
|
||||||
public async Task LoadPlugins()
|
public async Task LoadPlugins()
|
||||||
{
|
{
|
||||||
Commands = new List<DBCommand>();
|
|
||||||
Events = new List<DBEvent>();
|
|
||||||
SlashCommands = new List<DBSlashCommand>();
|
|
||||||
|
|
||||||
Config.Logger.Log("Loading plugins...", typeof(PluginLoader));
|
Config.Logger.Log("Loading plugins...", typeof(PluginLoader));
|
||||||
|
|
||||||
var loader = new Loader(Config.AppSettings["PluginFolder"], "dll");
|
var loader = new Loader(Config.AppSettings["PluginFolder"], "dll");
|
||||||
|
|||||||
Reference in New Issue
Block a user