Removed the WebUI. Removed the Modules

This commit is contained in:
2024-10-30 23:10:04 +02:00
parent f8df0f0254
commit 9e8bfbbe16
2133 changed files with 120 additions and 15581 deletions

View File

@@ -1,90 +0,0 @@
using DiscordBotCore;
using DiscordBotCore.Bot;
using DiscordBotCore.Loaders;
using DiscordBotCore.Others;
using DiscordBotCore.Others.Exceptions;
namespace DiscordBotWebUI.DiscordBot;
public class DiscordApplication
{
public bool IsRunning { get; private set; }
private Action<string, LogType> LogWriter { get; set; }
private Func<ModuleRequirement, Task> RequirementsSolver { get; set; }
public DiscordApplication(Action<string, LogType> logWriter, Func<ModuleRequirement, Task> requirementsSolver)
{
this.LogWriter = logWriter;
this.RequirementsSolver = requirementsSolver;
IsRunning = false;
}
private async Task<bool> LoadComponents()
{
await Application.CreateApplication(RequirementsSolver);
Application.Logger.SetOutFunction(LogWriter);
return Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("ServerID") &&
Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("token") &&
Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsKey("prefix");
}
public async Task Start()
{
if (!await LoadComponents())
{
Console.WriteLine("Failed to load components");
return;
}
var token = Application.CurrentApplication.ApplicationEnvironmentVariables.Get<string>("token");
var prefix = Application.CurrentApplication.ApplicationEnvironmentVariables.Get<string>("prefix");
var coreApplication = new DiscordBotApplication(token, prefix);
await coreApplication.StartAsync();
await RefreshPlugins(false);
IsRunning = true;
}
public async Task RefreshPlugins(bool quiet)
{
await LoadPlugins(quiet ? ["-q"] : null);
await InitializeInternalActionManager();
}
private async Task LoadPlugins(string[]? args)
{
var loader = new PluginLoader(Application.CurrentApplication.DiscordBotClient.Client);
if (args is not null && args.Contains("-q"))
{
await loader.LoadPlugins();
}
loader.OnCommandLoaded += (command) => {
Application.Logger.Log($"Command {command.Command} loaded successfully", LogType.Info);
};
loader.OnEventLoaded += (eEvent) => {
Application.Logger.Log($"Event {eEvent.Name} loaded successfully", LogType.Info);
};
loader.OnActionLoaded += (action) => {
Application.Logger.Log($"Action {action.ActionName} loaded successfully", LogType.Info);
};
loader.OnSlashCommandLoaded += (slashCommand) => {
Application.Logger.Log($"Slash Command {slashCommand.Name} loaded successfully", LogType.Info);
};
await loader.LoadPlugins();
}
private async Task InitializeInternalActionManager()
{
await Application.CurrentApplication.InternalActionManager.Initialize();
}
}