Removed the WebUI. Removed the Modules
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using DiscordBotCore.Interfaces.Modules;
|
||||
using System.Reflection;
|
||||
using DiscordBotCore.Modules;
|
||||
|
||||
namespace DiscordBotCore.Loaders
|
||||
{
|
||||
internal class ModuleLoader
|
||||
{
|
||||
private readonly List<ModuleData> _ModuleData;
|
||||
|
||||
public ModuleLoader(List<ModuleData> moduleFolder)
|
||||
{
|
||||
_ModuleData = moduleFolder;
|
||||
}
|
||||
|
||||
public Task LoadFileModules()
|
||||
{
|
||||
var paths = _ModuleData.Select(module => module.ModulePath);
|
||||
|
||||
foreach (var file in paths)
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly.LoadFrom(file);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Error loading module {file}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<List<IModule>> LoadModules()
|
||||
{
|
||||
var moduleType = typeof(IModule);
|
||||
var moduleTypes = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(s => s.GetTypes())
|
||||
.Where(p => moduleType.IsAssignableFrom(p) && !p.IsInterface);
|
||||
|
||||
var modules = new List<IModule>();
|
||||
foreach (var module in moduleTypes)
|
||||
{
|
||||
try
|
||||
{
|
||||
var instance = (IModule?)Activator.CreateInstance(module);
|
||||
if (instance is null)
|
||||
{
|
||||
Console.WriteLine($"Error loading module {module.Name}: Could not create instance");
|
||||
continue;
|
||||
}
|
||||
|
||||
modules.Add(instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Error loading module {module.Name}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(modules);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public sealed class PluginLoader
|
||||
SlashCommands.Clear();
|
||||
Actions.Clear();
|
||||
|
||||
Application.Logger.Log("Loading plugins...", this);
|
||||
Application.CurrentApplication.Logger.Log("Loading plugins...", this);
|
||||
|
||||
var loader = new Loader();
|
||||
|
||||
@@ -51,7 +51,7 @@ public sealed class PluginLoader
|
||||
|
||||
private void FileLoadedException(FileLoaderResult result)
|
||||
{
|
||||
Application.Logger.Log(result.ErrorMessage, this, LogType.Error);
|
||||
Application.CurrentApplication.Logger.Log(result.ErrorMessage, this, LogType.Error);
|
||||
}
|
||||
|
||||
private async void InitializeCommand(ICommandAction action)
|
||||
@@ -99,7 +99,7 @@ public sealed class PluginLoader
|
||||
|
||||
private void HandleError(Exception exception)
|
||||
{
|
||||
Application.Logger.Log(exception.Message, this, LogType.Error);
|
||||
Application.CurrentApplication.Logger.Log(exception.Message, this, LogType.Error);
|
||||
}
|
||||
|
||||
private void OnPluginLoaded(PluginLoaderResult result)
|
||||
|
||||
@@ -28,8 +28,8 @@ internal static class PluginLoaderExtensions
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Application.Logger.Log($"Error starting event {dbEvent.Name}: {e.Message}", typeof(PluginLoader), LogType.Error);
|
||||
Application.Logger.LogException(e, typeof(PluginLoader));
|
||||
Application.CurrentApplication.Logger.Log($"Error starting event {dbEvent.Name}: {e.Message}", typeof(PluginLoader), LogType.Error);
|
||||
Application.CurrentApplication.Logger.LogException(e, typeof(PluginLoader));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ internal static class PluginLoaderExtensions
|
||||
SocketGuild? guild = Application.CurrentApplication.DiscordBotClient.Client.GetGuild(guildId);
|
||||
if (guild is null)
|
||||
{
|
||||
Application.Logger.Log("Failed to get guild with ID " + guildId, typeof(PluginLoader), LogType.Error);
|
||||
Application.CurrentApplication.Logger.Log("Failed to get guild with ID " + guildId, typeof(PluginLoader), LogType.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user