Updated ICommandAction.cs and DBEvent.cs. Removed thread request from DBEvent and added special thread request to ICommandAction.cs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DiscordBotCore.Interfaces;
|
||||
using DiscordBotCore.Loaders;
|
||||
@@ -59,9 +60,9 @@ public class InternalActionManager
|
||||
{
|
||||
Application.CurrentApplication.Logger.Log($"Action {actionName} is not executable", this, LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
await Actions[actionName].Execute(args);
|
||||
await StartAction(Actions[actionName], args);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -70,4 +71,19 @@ public class InternalActionManager
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task StartAction(ICommandAction action, params string[]? args)
|
||||
{
|
||||
if (action.RequireOtherThread)
|
||||
{
|
||||
async void Start() => await action.Execute(args);
|
||||
|
||||
Thread thread = new(Start);
|
||||
thread.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
await action.Execute(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ public static class ArchiveManager
|
||||
/// <param name="fileName">The file name in the archive</param>
|
||||
/// <param name="archName">The archive location on the disk</param>
|
||||
/// <returns>An array of bytes that represents the Stream value from the file that was read inside the archive</returns>
|
||||
public static async Task<byte[]?> ReadStreamFromPakAsync(string fileName, string archName)
|
||||
public static async Task<byte[]?> ReadAllBytes(string fileName, string archName)
|
||||
{
|
||||
|
||||
archName = Application.CurrentApplication.ApplicationEnvironmentVariables["ArchiveFolder"] + archName;
|
||||
archName = Path.Combine(Application.CurrentApplication.ApplicationEnvironmentVariables["ArchiveFolder"], archName);
|
||||
|
||||
if (!File.Exists(archName))
|
||||
throw new Exception("Failed to load file !");
|
||||
@@ -49,6 +49,9 @@ public static class ArchiveManager
|
||||
|
||||
stream.Close();
|
||||
memoryStream.Close();
|
||||
|
||||
Console.WriteLine("Read file from archive: " + fileName);
|
||||
Console.WriteLine("Size: " + data.Length);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user