From 9014d78a7de150e6989b1f6eb9772849daa44d51 Mon Sep 17 00:00:00 2001 From: Wizzy69 Date: Fri, 4 Nov 2022 14:08:35 +0200 Subject: [PATCH] --- DiscordBot/DiscordBot.csproj | 2 +- DiscordBot/Program.cs | 53 +++++++++++++++++++-------- PluginManager/Database/SqlDatabase.cs | 1 + 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj index e4b4394..8fbd91a 100644 --- a/DiscordBot/DiscordBot.csproj +++ b/DiscordBot/DiscordBot.csproj @@ -8,7 +8,7 @@ False True - 1.0.1.1 + 1.0.1.0 diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs index 268e340..9056180 100644 --- a/DiscordBot/Program.cs +++ b/DiscordBot/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; @@ -386,23 +387,43 @@ public class Program break; } - if (Functions.GetOperatingSystem() == OperatingSystem.WINDOWS) + Console.Clear(); + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("A new version of the bot is available !"); + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("Current version : " + Assembly.GetExecutingAssembly().GetName().Version.ToString()); + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("New version : " + newVersion); + Console.ForegroundColor = ConsoleColor.White; + + Console.WriteLine("Changelog :"); + + List changeLog = await ServerCom.ReadTextFromURL("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/VersionData/DiscordBot"); + foreach (var item in changeLog) + Utilities.WriteColorText(item); + Console.WriteLine("Do you want to update the bot ? (y/n)"); + if (Console.ReadKey().Key == ConsoleKey.Y) { - var url = - $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0.zip"; - Process.Start(".\\Updater\\Updater.exe", - $"{newVersion} {url} {Process.GetCurrentProcess().ProcessName}"); - } - else - { - var url = - $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip"; - Settings.Variables.outputStream.WriteLine("Downloading update ..."); - await ServerCom.DownloadFileNoProgressAsync(url, "./update.zip"); - await File.WriteAllTextAsync("Install.sh", - "#!/bin/bash\nunzip -qq update.zip -d ./\nrm update.zip\nchmod +x SethDiscordBot\n./DiscordBot"); - Process.Start("Install.sh").WaitForExit(); - Environment.Exit(0); + + + if (Functions.GetOperatingSystem() == OperatingSystem.WINDOWS) + { + var url = + $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0.zip"; + Process.Start(".\\Updater\\Updater.exe", + $"{newVersion} {url} {Process.GetCurrentProcess().ProcessName}"); + } + else + { + var url = + $"https://github.com/Wizzy69/SethDiscordBot/releases/download/v{newVersion}/net6.0_linux.zip"; + Settings.Variables.outputStream.WriteLine("Downloading update ..."); + await ServerCom.DownloadFileNoProgressAsync(url, "./update.zip"); + await File.WriteAllTextAsync("Install.sh", + "#!/bin/bash\nunzip -qq update.zip -d ./\nrm update.zip\nchmod +x SethDiscordBot\n./DiscordBot"); + Process.Start("Install.sh").WaitForExit(); + Environment.Exit(0); + } } } diff --git a/PluginManager/Database/SqlDatabase.cs b/PluginManager/Database/SqlDatabase.cs index 65ccaf9..e1d2359 100644 --- a/PluginManager/Database/SqlDatabase.cs +++ b/PluginManager/Database/SqlDatabase.cs @@ -17,6 +17,7 @@ namespace PluginManager.Database Connection = new SQLiteConnection(ConnectionString); } + public async Task Open() { await Connection.OpenAsync();