Started working on UI for windows users. Fixed bug in actions not being loaded

This commit is contained in:
2024-05-26 01:08:38 +03:00
parent c87d1a89c5
commit 5345515512
42 changed files with 655 additions and 1290 deletions
+2 -1
View File
@@ -78,8 +78,9 @@ namespace DiscordBotCore
await CurrentApplication.PluginManager.UninstallMarkedPlugins();
await CurrentApplication.PluginManager.CheckForUpdates();
CurrentApplication.InternalActionManager = new InternalActionManager(CurrentApplication.ApplicationEnvironmentVariables["PluginFolder"], "*.dll");
CurrentApplication.InternalActionManager = new InternalActionManager(CurrentApplication.ApplicationEnvironmentVariables["PluginFolder"], "dll");
await CurrentApplication.InternalActionManager.Initialize();
}
+5
View File
@@ -14,6 +14,11 @@ public interface DBEvent
/// </summary>
string Description { get; }
/// <summary>
/// If the event requires another thread to run
/// </summary>
bool RequireOtherThread { get; }
/// <summary>
/// The method that is invoked when the event is loaded into memory
/// </summary>
+2 -2
View File
@@ -13,9 +13,9 @@ public class ActionsLoader
{
public delegate void ActionLoaded(string name, string typeName, bool success, Exception? e = null);
private readonly string _actionExtension = "dll";
private readonly string _actionExtension;
private readonly string _actionFolder = @"./Data/Plugins/";
private readonly string _actionFolder;
public ActionsLoader(string path, string extension)
{
@@ -21,13 +21,13 @@ internal static class PluginLoaderExtensions
throw new ArgumentNullException(nameof(dbEvent));
}
dbEvent.Start(pluginLoader._Client);
return true;
}
catch (Exception e)
{
Application.CurrentApplication.Logger.Log($"Error starting event {dbEvent.Name}: {e.Message}", typeof(PluginLoader), LogType.ERROR);
Application.CurrentApplication.Logger.LogException(e, typeof(PluginLoader));
return false;
}
}
+1 -1
View File
@@ -72,7 +72,7 @@ namespace DiscordBotCore.Others.Logger
public static LogMessage CreateFromException(Exception exception, object Sender)
{
LogMessage message = new LogMessage(exception.Message, Sender, LogType.ERROR);
LogMessage message = new LogMessage(exception.ToString(), Sender, LogType.ERROR);
return message;
}
}
+7
View File
@@ -37,6 +37,11 @@ public sealed class Logger : ILogger
return messageAsString;
}
private void LogToFile(string message)
{
System.IO.File.AppendAllText(Application.CurrentApplication.LogFile, message);
}
private string GenerateLogMessage(ILogMessage message, string customFormat)
{
string messageAsString = customFormat;
@@ -54,6 +59,7 @@ public sealed class Logger : ILogger
OnRawLog?.Invoke(this, message);
string messageAsString = GenerateLogMessage(message, format);
OnFormattedLog?.Invoke(this, new ILogger.FormattedMessage() { Message = messageAsString, Type = message.LogMessageType });
LogToFile(messageAsString);
}
public void Log(ILogMessage message)
@@ -61,6 +67,7 @@ public sealed class Logger : ILogger
OnRawLog?.Invoke(this, message);
string messageAsString = GenerateLogMessage(message);
OnFormattedLog?.Invoke(this, new ILogger.FormattedMessage() { Message = messageAsString, Type = message.LogMessageType }) ;
LogToFile(messageAsString);
}
public void Log(string message, LogType logType, string format) => Log(new LogMessage(message, logType), format);