@page "/"
@using DiscordBotCore.Others.Exceptions
@using DiscordBotWebUI.Components.Pages.Setup
@using DiscordBotWebUI.DiscordBot
@inject DialogService DialogService
@code {
private string? _TextValue;
private DiscordBotStartup _DiscordBotStartup = null!;
protected override async void OnInitialized()
{
_DiscordBotStartup = new DiscordBotStartup(FixModules);
await _DiscordBotStartup.CreateApplication();
}
private async Task FixModules(ModuleRequirement requirements)
{
if(!requirements.RequireAny)
{
return;
}
await DialogService.OpenAsync("Please select one of the following to download ...", new Dictionary()
{
{"Requirements", requirements}
}, new DialogOptions() { Width = "75%", Height = "75%" });
}
private async void Initialize()
{
_DiscordBotStartup.Log += async (sender, str) => {
_TextValue += str + "\n";
await InvokeAsync(StateHasChanged);
};
dynamic result = _DiscordBotStartup.LoadComponents();
if (!result)
{
result = await DialogService.OpenAsync("Please complete this setup before starting the bot", new Dictionary());
if (result != true)
{
Environment.Exit(0);
}
}
await _DiscordBotStartup.PrepareBot();
await _DiscordBotStartup.RefreshPlugins(false);
}
}