Updated ICommandAction.cs and DBEvent.cs. Removed thread request from DBEvent and added special thread request to ICommandAction.cs

This commit is contained in:
2024-07-22 19:20:17 +03:00
parent 08c5febd66
commit 8c338820c5
42 changed files with 691 additions and 26 deletions

View File

@@ -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);
}
}
}