Updated bootstrap and merged gitlab project
This commit is contained in:
@@ -8,22 +8,19 @@ namespace DiscordBotWebUI.DiscordBot;
|
||||
|
||||
public class DiscordBotStartup
|
||||
{
|
||||
public event EventHandler<string>? Log;
|
||||
private void WriteLog(string message)
|
||||
{
|
||||
Log?.Invoke(this, message);
|
||||
}
|
||||
|
||||
private readonly Func<ModuleRequirement, Task> RequireInstallModule;
|
||||
public required Func<ModuleRequirement, Task> RequirementsSolver { get; set; }
|
||||
|
||||
public DiscordBotStartup(Func<ModuleRequirement, Task> requirementHandler)
|
||||
internal delegate void LogEventHandler(string message, LogType type);
|
||||
internal LogEventHandler Log;
|
||||
|
||||
private void WriteLog(string message, LogType logType)
|
||||
{
|
||||
this.RequireInstallModule = requirementHandler;
|
||||
Log?.Invoke(message, logType);
|
||||
}
|
||||
|
||||
public async Task CreateApplication()
|
||||
{
|
||||
await Application.CreateApplication(RequireInstallModule);
|
||||
await Application.CreateApplication(RequirementsSolver);
|
||||
}
|
||||
|
||||
public bool LoadComponents()
|
||||
@@ -50,7 +47,7 @@ public class DiscordBotStartup
|
||||
await LoadPlugins(quiet ? ["-q"] : null);
|
||||
await InitializeInternalActionManager();
|
||||
}
|
||||
|
||||
|
||||
private async Task LoadPlugins(string[]? args)
|
||||
{
|
||||
var loader = new PluginLoader(Application.CurrentApplication.DiscordBotClient.Client);
|
||||
@@ -58,30 +55,26 @@ public class DiscordBotStartup
|
||||
{
|
||||
await loader.LoadPlugins();
|
||||
}
|
||||
|
||||
loader.OnCommandLoaded += (command) =>
|
||||
{
|
||||
|
||||
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.OnEventLoaded += (eEvent) => {
|
||||
Application.Logger.Log($"Event {eEvent.Name} loaded successfully", LogType.Info);
|
||||
};
|
||||
|
||||
loader.OnActionLoaded += (action) =>
|
||||
{
|
||||
|
||||
loader.OnActionLoaded += (action) => {
|
||||
Application.Logger.Log($"Action {action.ActionName} loaded successfully", LogType.Info);
|
||||
};
|
||||
|
||||
loader.OnSlashCommandLoaded += (slashCommand) =>
|
||||
{
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user