Merged projects with plugins and modules

This commit is contained in:
2024-07-22 01:18:00 +03:00
parent 1fd065f4c2
commit 8ace51c840
59 changed files with 1669 additions and 73 deletions

View File

@@ -16,12 +16,12 @@ public class InternalActionManager
PluginLoader.Actions.ForEach(action =>
{
if (action.RunType == InternalActionRunType.ON_CALL || action.RunType == InternalActionRunType.BOTH)
if (action.RunType == InternalActionRunType.OnCall || action.RunType == InternalActionRunType.OnStartupAndCall)
{
if (this.Actions.ContainsKey(action.ActionName))
{
// This should never happen. If it does, log it and return
Application.CurrentApplication.Logger.Log($"Action {action.ActionName} already exists", this, LogType.ERROR);
Application.CurrentApplication.Logger.Log($"Action {action.ActionName} already exists", this, LogType.Error);
return;
}
@@ -49,15 +49,15 @@ public class InternalActionManager
{
if (!Actions.ContainsKey(actionName))
{
Application.CurrentApplication.Logger.Log($"Action {actionName} not found", this, LogType.ERROR);
Application.CurrentApplication.Logger.Log($"Action {actionName} not found", this, LogType.Error);
return false;
}
try
{
if (Actions[actionName].RunType == InternalActionRunType.ON_STARTUP)
if (Actions[actionName].RunType == InternalActionRunType.OnStartup)
{
Application.CurrentApplication.Logger.Log($"Action {actionName} is not executable", this, LogType.ERROR);
Application.CurrentApplication.Logger.Log($"Action {actionName} is not executable", this, LogType.Error);
return false;
}
@@ -66,7 +66,7 @@ public class InternalActionManager
}
catch (Exception e)
{
Application.CurrentApplication.Logger.Log(e.Message, type: LogType.ERROR, Sender: this);
Application.CurrentApplication.Logger.Log(e.Message, type: LogType.Error, Sender: this);
return false;
}
}

View File

@@ -87,7 +87,7 @@ public static class ArchiveManager
}
catch (Exception ex)
{
Application.CurrentApplication.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.ERROR); // Write the error to a file
Application.CurrentApplication.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.Error); // Write the error to a file
await Task.Delay(100);
return await ReadFromPakAsync(fileName, archFile);
}
@@ -123,7 +123,7 @@ public static class ArchiveManager
}
catch (Exception ex)
{
Application.CurrentApplication.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.ERROR);
Application.CurrentApplication.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.Error);
}
currentZipFile++;
@@ -158,7 +158,7 @@ public static class ArchiveManager
}
catch (Exception ex)
{
Application.CurrentApplication.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.ERROR);
Application.CurrentApplication.Logger.Log(ex.Message, typeof(ArchiveManager), LogType.Error);
}
await Task.Delay(10);

View File

@@ -7,42 +7,42 @@ namespace DiscordBotCore.Others;
public class DbCommandExecutingArguments
{
public SocketCommandContext context { get; init; }
public string cleanContent { get; init; }
public string commandUsed { get; init; }
public string[]? arguments { get; init; }
public ISocketMessageChannel Channel => context.Channel;
public SocketCommandContext Context { get; init; }
public string CleanContent { get; init; }
public string CommandUsed { get; init; }
public string[]? Arguments { get; init; }
public ISocketMessageChannel Channel => Context.Channel;
public DbCommandExecutingArguments(
SocketCommandContext context, string cleanContent, string commandUsed, string[]? arguments)
{
this.context = context;
this.cleanContent = cleanContent;
this.commandUsed = commandUsed;
this.arguments = arguments;
this.Context = context;
this.CleanContent = cleanContent;
this.CommandUsed = commandUsed;
this.Arguments = arguments;
}
public DbCommandExecutingArguments(SocketUserMessage? message, DiscordSocketClient client)
{
context = new SocketCommandContext(client, message);
Context = new SocketCommandContext(client, message);
var pos = 0;
if (message.HasMentionPrefix(client.CurrentUser, ref pos))
{
var mentionPrefix = "<@" + client.CurrentUser.Id + ">";
cleanContent = message.Content.Substring(mentionPrefix.Length + 1);
CleanContent = message.Content.Substring(mentionPrefix.Length + 1);
}
else
{
cleanContent = message.Content.Substring(Application.CurrentApplication.DiscordBotClient.BotPrefix.Length);
CleanContent = message.Content.Substring(Application.CurrentApplication.DiscordBotClient.BotPrefix.Length);
}
var split = cleanContent.Split(' ');
var split = CleanContent.Split(' ');
string[]? argsClean = null;
if (split.Length > 1)
argsClean = string.Join(' ', split, 1, split.Length - 1).Split(' ');
commandUsed = split[0];
arguments = argsClean;
CommandUsed = split[0];
Arguments = argsClean;
}
}

View File

@@ -7,10 +7,10 @@ namespace DiscordBotCore.Others;
/// </summary>
public enum LogType
{
INFO,
WARNING,
ERROR,
CRITICAL
Info,
Warning,
Error,
Critical
}
public enum UnzipProgressType
@@ -21,9 +21,9 @@ public enum UnzipProgressType
public enum InternalActionRunType
{
ON_STARTUP,
ON_CALL,
BOTH
OnStartup,
OnCall,
OnStartupAndCall
}
[Flags]