improved save method

This commit is contained in:
2022-08-20 17:44:19 +03:00
parent 3ba45790e7
commit 6da9828e5c
7 changed files with 101 additions and 33 deletions

View File

@@ -261,7 +261,8 @@ public class ConsoleCommandsHandler
return;
client.StopAsync();
client.DisposeAsync();
Config.SaveConfig();
Config.SaveConfig(SaveType.NORMAL);
Config.SaveConfig(SaveType.BACKUP);
Console.WriteLine("Bot is closing in 2 seconds ! Please wait to save data !");
Thread.Sleep(2000);
Environment.Exit(0);
@@ -307,7 +308,7 @@ public class ConsoleCommandsHandler
{
if (Functions.GetOperatingSystem() == Others.OperatingSystem.WINDOWS)
{
Process.Start("DiscordBot.exe ", $"/remplug {plugName}");
Process.Start("DiscordBot.exe", $"/remplug {plugName}");
await Task.Delay(100);
Environment.Exit(0);
}
@@ -345,7 +346,7 @@ public class ConsoleCommandsHandler
Console.WriteLine("Found: " + tuple.ToString());
Config.PluginConfig.InstalledPlugins.Remove(tuple);
Config.RemovePluginVersion(plugName);
Config.SaveConfig();
Config.SaveConfig(SaveType.NORMAL);
}
Console.WriteLine("Removed the plugin DLL. Checking for other files ...");
@@ -374,6 +375,21 @@ public class ConsoleCommandsHandler
});
AddCommand("reload", "Reload the bot with all plugins", () =>
{
if (Functions.GetOperatingSystem() == Others.OperatingSystem.WINDOWS)
{
Process.Start("DiscordBot.exe", $"lp");
HandleCommand("sd");
}
else
{
Process.Start("./DiscordBot", $"lp");
HandleCommand("sd");
}
});
//Sort the commands by name
commandList.Sort((x, y) => x.CommandName.CompareTo(y.CommandName));
}