diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj index 1f88f48..5a15b95 100644 --- a/DiscordBot/DiscordBot.csproj +++ b/DiscordBot/DiscordBot.csproj @@ -8,7 +8,7 @@ False True - 1.0.1.1 + 1.0.1.2 diff --git a/PluginManager/Items/ConsoleCommandsHandler.cs b/PluginManager/Items/ConsoleCommandsHandler.cs index a8f5dde..7cba8b0 100644 --- a/PluginManager/Items/ConsoleCommandsHandler.cs +++ b/PluginManager/Items/ConsoleCommandsHandler.cs @@ -322,15 +322,19 @@ public class ConsoleCommandsHandler try { var pName = string.Join(' ', args, 1, args.Length - 1); - var client = new HttpClient(); - var url = (await manager.GetPluginLinkByName(pName))[1]; - if (url is null) throw new Exception($"Invalid plugin name {pName}."); - var s = await client.GetStreamAsync(url); - var str = new MemoryStream(); - await s.CopyToAsync(str); - var asmb = Assembly.Load(str.ToArray()); + using (var client = new HttpClient()) + { + var url = (await manager.GetPluginLinkByName(pName))[1]; + if (url is null) throw new Exception($"Invalid plugin name {pName}."); + var s = await client.GetStreamAsync(url); + var str = new MemoryStream(); + await s.CopyToAsync(str); + var asmb = Assembly.Load(str.ToArray()); + + await PluginLoader.LoadPluginFromAssembly(asmb, this.client); + } + - await PluginLoader.LoadPluginFromAssembly(asmb, this.client); } catch (Exception ex) { @@ -351,6 +355,7 @@ public class ConsoleCommandsHandler catch (Exception ex) { Logger.WriteLine(ex.Message); + Logger.WriteErrFile(ex); } }); diff --git a/PluginManager/Logger.cs b/PluginManager/Logger.cs index 1e51781..7242160 100644 --- a/PluginManager/Logger.cs +++ b/PluginManager/Logger.cs @@ -126,5 +126,6 @@ namespace PluginManager if (!isInitialized) throw new Exception("Logger is not initialized"); WriteErrFile(ex.ToString()); } + } } diff --git a/PluginManager/Online/Updates/PluginUpdater.cs b/PluginManager/Online/Updates/PluginUpdater.cs index 1b2bd48..b38a691 100644 --- a/PluginManager/Online/Updates/PluginUpdater.cs +++ b/PluginManager/Online/Updates/PluginUpdater.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using System.Collections.Generic; using PluginManager.Items; using PluginManager.Others; @@ -30,12 +31,22 @@ public class PluginUpdater return false; } - public static async Task Download(string pakName) + public static async Task> GetInfo(string pakName) { + Utilities.WriteColorText("An update was found for &g" + pakName + "&c. Version: &r" + (await ServerCom.GetVersionOfPackageFromWeb(pakName))?.ToShortString() + "&c. Current Version: &y" + ServerCom.GetVersionOfPackage(pakName)?.ToShortString()); + + List fileInfo = await ServerCom.ReadTextFromURL(""); + return fileInfo; + } + + public static async Task Download(string pakName) + { + var pakUpdateInfo = await GetInfo(pakName); + Logger.Log(string.Join("\n", pakUpdateInfo)); await ConsoleCommandsHandler.ExecuteCommad("dwplug " + pakName); } } \ No newline at end of file diff --git a/SethDiscordBot.sln b/SethDiscordBot.sln index bc1f6ac..863fabf 100644 --- a/SethDiscordBot.sln +++ b/SethDiscordBot.sln @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roles", "..\DiscordBotItems EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DBEconomy", "..\DiscordBotItems\Plugins\DBEconomy\DBEconomy.csproj", "{0321365B-4ADC-4B1D-BD98-F573D36E83B2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "..\DiscordBotItems\Updater\Updater.csproj", "{1A411BE0-6AE4-4129-A0BD-0D1D5D4E2D1A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -51,6 +53,10 @@ Global {0321365B-4ADC-4B1D-BD98-F573D36E83B2}.Debug|Any CPU.Build.0 = Debug|Any CPU {0321365B-4ADC-4B1D-BD98-F573D36E83B2}.Release|Any CPU.ActiveCfg = Release|Any CPU {0321365B-4ADC-4B1D-BD98-F573D36E83B2}.Release|Any CPU.Build.0 = Release|Any CPU + {1A411BE0-6AE4-4129-A0BD-0D1D5D4E2D1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A411BE0-6AE4-4129-A0BD-0D1D5D4E2D1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A411BE0-6AE4-4129-A0BD-0D1D5D4E2D1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A411BE0-6AE4-4129-A0BD-0D1D5D4E2D1A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE