The library can now be used for Windows exclusive bots (Made with WinForm or Wpf)

This commit is contained in:
2022-11-13 16:28:44 +02:00
parent 655f5e2ce0
commit 5bb13aa4a6
11 changed files with 202 additions and 127 deletions

65
PluginManager/Logger.cs Normal file
View File

@@ -0,0 +1,65 @@
using Discord;
namespace PluginManager
{
public static class Logger
{
public static bool isConsole = true;
public delegate void LogEventHandler(string Message);
public static event LogEventHandler LogEvent;
public static void Log(string Message)
{
LogEvent?.Invoke(Message);
}
public static void Log(string Message, params object[] Args)
{
LogEvent?.Invoke(string.Format(Message, Args));
}
public static void Log(IMessage message, bool newLine)
{
LogEvent?.Invoke(message.Content);
if (newLine)
LogEvent?.Invoke("\n");
}
public static void WriteLine(string? message)
{
if (message is not null)
LogEvent?.Invoke(message + '\n');
}
public static void LogError(System.Exception ex)
{
string message = "[ERROR]" + ex.Message;
LogEvent?.Invoke(message + '\n');
}
public static void LogError(string? message)
{
if (message is not null)
LogEvent?.Invoke("[ERROR]" + message + '\n');
}
public static void WriteLine()
{
LogEvent?.Invoke("\n");
}
public static void Write(string message)
{
LogEvent?.Invoke(message);
}
public static void Write(char c)
{
LogEvent?.Invoke($"{c}");
}
}
}