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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user