Started working on UI for windows users. Fixed bug in actions not being loaded
This commit is contained in:
65
DiscordBotUI/Program.cs
Normal file
65
DiscordBotUI/Program.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Discord.WebSocket;
|
||||
|
||||
using DiscordBotCore.Interfaces;
|
||||
using DiscordBotCore.Others;
|
||||
using DiscordBotCore.Others.Actions;
|
||||
|
||||
using DiscordBotUI_Windows.WindowsForms;
|
||||
|
||||
namespace DiscordBotUI
|
||||
{
|
||||
|
||||
public class DiscordEventUI : DBEvent
|
||||
{
|
||||
public string Name => "DiscordUI";
|
||||
|
||||
public bool RequireOtherThread => true;
|
||||
public string Description => "Discord UI desc";
|
||||
|
||||
public void Start(DiscordSocketClient client)
|
||||
{
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
Application.Run(new MainWindow());
|
||||
});
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public class ConsoleStartAction : ICommandAction
|
||||
{
|
||||
public string ActionName => "ui";
|
||||
|
||||
public string? Description => "UI Set of actions";
|
||||
|
||||
public string? Usage => "ui <option>";
|
||||
|
||||
public IEnumerable<InternalActionOption> ListOfOptions => [
|
||||
new InternalActionOption("start", "Starts the UI")
|
||||
];
|
||||
|
||||
public InternalActionRunType RunType => InternalActionRunType.ON_CALL;
|
||||
|
||||
public Task Execute(string[]? args)
|
||||
{
|
||||
if(args == null || args.Length == 0)
|
||||
{
|
||||
Console.WriteLine("Please provide an option");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
if(args[0] == "start")
|
||||
{
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
Application.Run(new MainWindow());
|
||||
});
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user