Updated the settings page
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
@page "/settings"
|
@page "/settings"
|
||||||
@using DiscordBotCore
|
@using DiscordBotCore
|
||||||
|
@inject NotificationService NotificationService
|
||||||
|
|
||||||
<RadzenPanel>
|
<RadzenPanel>
|
||||||
<HeaderTemplate>
|
<HeaderTemplate>
|
||||||
@@ -44,6 +45,37 @@
|
|||||||
private string _Prefix = string.Empty;
|
private string _Prefix = string.Empty;
|
||||||
private string _ServerIds = string.Empty;
|
private string _ServerIds = string.Empty;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
base.OnInitialized();
|
||||||
|
|
||||||
|
if(Application.CurrentApplication.ApplicationEnvironmentVariables.TryGetValue("token", out var token))
|
||||||
|
{
|
||||||
|
_Token = token as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Application.CurrentApplication.ApplicationEnvironmentVariables.TryGetValue("prefix", out var prefix))
|
||||||
|
{
|
||||||
|
_Prefix = prefix as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Application.CurrentApplication.ApplicationEnvironmentVariables.TryGetValue("ServerID", out var serverIds))
|
||||||
|
{
|
||||||
|
if (serverIds is List<object> listServerIds)
|
||||||
|
{
|
||||||
|
foreach(var item in listServerIds)
|
||||||
|
{
|
||||||
|
_ServerIds += $"{item}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
_ServerIds.TrimEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private async Task SaveChanges()
|
private async Task SaveChanges()
|
||||||
{
|
{
|
||||||
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("token", _Token);
|
Application.CurrentApplication.ApplicationEnvironmentVariables.Set("token", _Token);
|
||||||
@@ -53,7 +85,8 @@
|
|||||||
string[] values = _ServerIds.Split('\n');
|
string[] values = _ServerIds.Split('\n');
|
||||||
foreach(var value in values)
|
foreach(var value in values)
|
||||||
{
|
{
|
||||||
if(ulong.TryParse(value, out ulong actualValue))
|
string clearValue = value.TrimEnd().Replace("\r", "");
|
||||||
|
if(ulong.TryParse(clearValue, out ulong actualValue))
|
||||||
{
|
{
|
||||||
serverIds.Add(actualValue);
|
serverIds.Add(actualValue);
|
||||||
}
|
}
|
||||||
@@ -63,6 +96,7 @@
|
|||||||
|
|
||||||
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
await Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
||||||
|
|
||||||
|
NotificationService.Notify(NotificationSeverity.Success, "Configuration", "Configuration has been saved !", 4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ServerIDsValueChanged(string obj)
|
private void ServerIDsValueChanged(string obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user