Removed the WebUI. Removed the Modules

This commit is contained in:
2024-10-30 23:10:04 +02:00
parent f8df0f0254
commit 9e8bfbbe16
2133 changed files with 120 additions and 15581 deletions

View File

@@ -1,68 +0,0 @@
@using DiscordBotCore
@using DiscordBotCore.Plugin
@using DiscordBotWebUI.Types
<RadzenDataGrid AllowColumnResize="true" PageSize="5" AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Left" Data="ListedItems">
<Columns>
<RadzenDataGridColumn Property="@nameof(MarketItem.Name)" Title="Item Name"></RadzenDataGridColumn>
<RadzenDataGridColumn Property="@nameof(MarketItem.Author)" Title="Item Author"></RadzenDataGridColumn>
<RadzenDataGridColumn Property="@nameof(MarketItem.Description)" Title="Item Description"></RadzenDataGridColumn>
<RadzenDataGridColumn Property="@nameof(MarketItem.Type)" Title="Item type"></RadzenDataGridColumn>
<RadzenDataGridColumn Title="Item Download">
<Template Context="item">
<RadzenButton Click="() => DownloadAction(item.Name, item.Type)">Download</RadzenButton>
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
<RadzenProgressBar Value="_ProgressValue" Visible="_ProgressBarVisible"/>
@code {
private float _ProgressValue = .0f;
private bool _ProgressBarVisible = false;
[Parameter]
public List<MarketItem> ListedItems { get; set; }
public async void DownloadAction(string name, ItemType type)
{
switch (type)
{
case ItemType.Module:
await DownloadModule(name);
break;
case ItemType.Plugin:
await DownloadPlugin(name);
break;
}
}
private async Task DownloadModule(string moduleName)
{
_ProgressBarVisible = true;
IProgress<float> downloadProgress = new Progress<float>(p => {
_ProgressValue = p;
StateHasChanged();
});
await Application.CurrentApplication.ModuleManager.InstallModule(moduleName, downloadProgress);
_ProgressBarVisible = false;
}
private async Task DownloadPlugin(string pluginName)
{
_ProgressBarVisible = true;
IProgress<float> downloadProgress = new Progress<float>(p => {
_ProgressValue = p;
StateHasChanged();
});
PluginOnlineInfo? pluginInfo = await Application.CurrentApplication.PluginManager.GetPluginDataByName(pluginName);
if (pluginInfo is null)
return;
await Application.CurrentApplication.PluginManager.InstallPlugin(pluginInfo, downloadProgress);
_ProgressBarVisible = false;
}
}

View File

@@ -1,8 +0,0 @@
@code {
[Parameter] public Action CompleteSetup { get; set; }
}
<RadzenHeading Size="H4">Final Setup</RadzenHeading>
<p>Your bot is almost ready! Click 'Finish' to complete the setup.</p>
<RadzenButton Text="Finish" Click="CompleteSetup" Style="margin-top: 20px;" />

View File

@@ -1,48 +0,0 @@
@using DiscordBotCore
@using DiscordBotCore.Modules
@using DiscordBotCore.Others.Exceptions
@using DiscordBotWebUI.Types
@code {
[Parameter] public Action NextStep { get; set; }
[Parameter] public ModuleRequirement ModuleRequirementReference { get; set; }
private List<MarketItem> MarketItems = new List<MarketItem>();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
foreach(var requirement in ModuleRequirementReference.RequiredModulesWithTypes)
{
var modulesWithType = await Application.CurrentApplication.ModuleManager.ServerGetAllModules(requirement);
AppendToList(modulesWithType);
}
foreach (var moduleName in ModuleRequirementReference.RequiredModulesWithNames)
{
var module = await Application.CurrentApplication.ModuleManager.ServerGetModuleWithName(moduleName);
MarketItem item = new MarketItem(module.ModuleName, module.ModuleAuthor, module.ModuleDescription, ItemType.Module);
MarketItems.Add(item);
}
}
private void AppendToList(List<ModuleOnlineData> listOfModules)
{
foreach (var module in listOfModules)
{
MarketItem item = new MarketItem(module.ModuleName, module.ModuleAuthor, module.ModuleDescription, ItemType.Module);
MarketItems.Add(item);
}
}
}
<RadzenHeading Size="H4">Download Dependencies</RadzenHeading>
<p>The bot needs to download certain files to function properly.</p>
@if (MarketItems.Any())
{
<Marketplace ListedItems="MarketItems"/>
}
<RadzenButton Click="NextStep" Text="Next"/>

View File

@@ -1,60 +0,0 @@
@using DiscordBotCore
@code {
[Parameter] public Action NextStep { get; set; }
private string BotToken { get; set; }
private string BotPrefix { get; set; }
private List<ulong> BotServers { get; set; }
private string BotServersString { get; set; }
private async void DoNextStep()
{
if(string.IsNullOrEmpty(BotToken) || string.IsNullOrEmpty(BotPrefix) || string.IsNullOrEmpty(BotServersString))
{
return;
}
if(BotServersString.Contains(","))
{
BotServersString = BotServersString.Replace(",", ";");
}
var stringList = BotServersString.Split(';');
BotServers = new List<ulong>();
foreach(var serverId in stringList)
{
if(ulong.TryParse(serverId, out ulong id))
{
BotServers.Add(id);
}
}
if (!BotServers.Any())
{
return;
}
Application.CurrentApplication.ApplicationEnvironmentVariables.Add("token", BotToken);
Application.CurrentApplication.ApplicationEnvironmentVariables.Add("prefix", BotPrefix);
Application.CurrentApplication.ApplicationEnvironmentVariables.Add("ServerID", BotServers);
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
NextStep.Invoke();
}
}
<RadzenHeading Size="H4">Basic Configuration</RadzenHeading>
<p>Please provide some basic settings to get started.</p>
<RadzenLabel Text="Token" />
<RadzenTextBox @bind-Value="BotToken" Placeholder="Enter bot token here" Style="width: 100%;" />
<RadzenLabel Text="Prefix" Style="margin-top: 10px;" />
<RadzenTextBox @bind-Value="BotPrefix" Placeholder="Enter the prefix here" Style="width: 100%;" />
<RadzenLabel Text="Server Ids separated by ;" Style="margin-top: 20px;" />
<RadzenTextBox @bind-Value="BotServersString" Placeholder="Enter Server Ids here. Separated by commas (;)" Style="width: 100%;" />
<RadzenButton Text="Next" Click="DoNextStep" Style="margin-top: 30px;" />

View File

@@ -1,7 +0,0 @@
@code {
[Parameter] public Action NextStep { get; set; }
}
<RadzenHeading Size="H4">Welcome to the Bot Setup Wizard</RadzenHeading>
<p>This setup wizard will guide you through the process of configuring your bot and downloading the necessary dependencies.</p>
<RadzenButton Text="Start Setup" Click="NextStep" Style="margin-top: 20px;" />