This commit is contained in:
2022-05-22 19:37:15 +03:00
parent 6e09fa9738
commit 0160b011dd
2 changed files with 30 additions and 4 deletions

View File

@@ -31,16 +31,18 @@ namespace DiscordBotGUI.Settings
{ {
try try
{ {
textbox1.Text = "";
var files = System.IO.Directory.EnumerateFiles("./Data/Plugins/Commands/"); var files = System.IO.Directory.EnumerateFiles("./Data/Plugins/Commands/");
if (files == null || files.Count() < 1) return; if (files == null || files.Count() < 1) return;
foreach (var file in files) foreach (var file in files)
textbox1.Text += file + "\n"; textbox1.Text += file.Split('/')[file.Split('/').Length - 1] + "\n";
} }
catch { } catch { }
} }
private async void LoadComboBox() private async void LoadComboBox()
{ {
comboBox1.Items = null;
commands = await PluginManager.Online.ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins"); commands = await PluginManager.Online.ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
if (commands == null) return; if (commands == null) return;
string[] plugins = commands.ToArray(); string[] plugins = commands.ToArray();
@@ -55,7 +57,11 @@ namespace DiscordBotGUI.Settings
if (!plugins[i].Contains(OS) || !plugins[i].Contains("Commands")) if (!plugins[i].Contains(OS) || !plugins[i].Contains("Commands"))
continue; continue;
string[] info = plugins[i].Split(','); string[] info = plugins[i].Split(',');
if (System.IO.Directory.EnumerateFiles("./Data/Plugins/Commands/").Any(x => x.EndsWith(info[0] + ".dll")))
continue;
data.Add($"{info[0]} - {info[1]} - {info[2]}"); data.Add($"{info[0]} - {info[1]} - {info[2]}");
} }
@@ -77,11 +83,18 @@ namespace DiscordBotGUI.Settings
if (URL == null) return; if (URL == null) return;
IProgress<float> progress = new Progress<float>(value => IProgress<float> progress = new Progress<float>(async value =>
{ {
label1.Content = $"Downloading {pluginName} {MathF.Round(value, 2)}%"; label1.Content = $"Downloading {pluginName} {MathF.Round(value, 2)}%";
if (value == 1f) if (value == 1f)
{
label1.Content = "Successfully Downloaded " + pluginName; label1.Content = "Successfully Downloaded " + pluginName;
LoadData();
LoadComboBox();
await Task.Delay(5000);
label1.Content = "";
}
progressBar1.Value = value; progressBar1.Value = value;
}); });

View File

@@ -25,6 +25,7 @@ namespace DiscordBotGUI.Settings
button1.Click += async (sender, e) => button1.Click += async (sender, e) =>
{ {
await Download(); await Download();
}; };
} }
@@ -35,15 +36,17 @@ namespace DiscordBotGUI.Settings
try try
{ {
textbox1.IsReadOnly = false; textbox1.IsReadOnly = false;
textbox1.Text = "";
var files = System.IO.Directory.EnumerateFiles("./Data/Plugins/Events/"); var files = System.IO.Directory.EnumerateFiles("./Data/Plugins/Events/");
if (files == null || files.Count() < 1) return; if (files == null || files.Count() < 1) return;
foreach (var file in files) foreach (var file in files)
textbox1.Text += file + "\n"; textbox1.Text += file.Split('/')[file.Split('/').Length - 1] + "\n";
} }
catch { } catch { }
} }
private async void LoadComboBox() private async void LoadComboBox()
{ {
comboBox1.Items = null;
events = await PluginManager.Online.ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins"); events = await PluginManager.Online.ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
if (events == null) return; if (events == null) return;
string[] plugins = events.ToArray(); string[] plugins = events.ToArray();
@@ -59,6 +62,9 @@ namespace DiscordBotGUI.Settings
continue; continue;
string[] info = plugins[i].Split(','); string[] info = plugins[i].Split(',');
if (System.IO.Directory.EnumerateFiles("./Data/Plugins/Events/").Any(x => x.EndsWith(info[0] + ".dll")))
continue;
data.Add($"{info[0]} - {info[1]} - {info[2]}"); data.Add($"{info[0]} - {info[1]} - {info[2]}");
} }
@@ -78,11 +84,18 @@ namespace DiscordBotGUI.Settings
if (URL == null) return; if (URL == null) return;
IProgress<float> progress = new Progress<float>(value => IProgress<float> progress = new Progress<float>(async value =>
{ {
label1.Content = $"Downloading {pluginName} {MathF.Round(value, 2)}%"; label1.Content = $"Downloading {pluginName} {MathF.Round(value, 2)}%";
if (value == 1f) if (value == 1f)
{
label1.Content = "Successfully Downloaded " + pluginName; label1.Content = "Successfully Downloaded " + pluginName;
LoadData();
LoadComboBox();
await Task.Delay(5000);
label1.Content = "";
}
progressBar1.Value = value; progressBar1.Value = value;
}); });