The ability to remove a plugin has been added

This commit is contained in:
2022-08-17 20:12:31 +03:00
parent 8b36c086ef
commit debdc58646
5 changed files with 103 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ public class Program
{
private static bool loadPluginsOnStartup;
private static bool listPluginsAtStartup;
private static ConsoleCommandsHandler consoleCommandsHandler;
/// <summary>
/// The main entry point for the application.
@@ -33,6 +34,7 @@ public class Program
Directory.CreateDirectory("./Data/Plugins/Events");
PreLoadComponents().Wait();
if (!Config.ContainsKey("ServerID"))
{
do
@@ -105,7 +107,7 @@ public class Program
/// <param name="discordbooter">The discord booter used to start the application</param>
private static void NoGUI(Boot discordbooter)
{
var consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
#if DEBUG
Console.WriteLine();
consoleCommandsHandler.HandleCommand("lp");
@@ -118,10 +120,11 @@ public class Program
{
//Console_Utilities.WriteColorText("&rSethBot (&yDEBUG&r) &c> ", false);
var cmd = Console.ReadLine();
if (!consoleCommandsHandler.HandleCommand(cmd!,
if (!consoleCommandsHandler.HandleCommand(cmd!
#if DEBUG
false
, false
#endif
) && cmd.Length > 0)
Console.WriteLine("Failed to run command " + cmd);
}
@@ -199,8 +202,11 @@ public class Program
/// <param name="args">The arguments</param>
private static async Task HandleInput(string[] args)
{
var b = await StartNoGUI();
consoleCommandsHandler = new ConsoleCommandsHandler(b.client);
var len = args.Length;
if (len == 3 && args[0] == "/download")
{
var url = args[1];
@@ -211,6 +217,17 @@ public class Program
return;
}
if (len > 0 && args[0] == "/remplug")
{
string plugName = Functions.MergeStrings(args, 1);
Console.WriteLine("Starting to remove " + plugName);
await ConsoleCommandsHandler.ExecuteCommad("remplug " + plugName);
loadPluginsOnStartup = true;
len = 0;
}
if (len > 0 && (args.Contains("--cmd") || args.Contains("--args") || args.Contains("--nomessage")))
{
if (args.Contains("lp") || args.Contains("loadplugins"))
@@ -222,10 +239,10 @@ public class Program
}
if (len == 0 || (args[0] != "--exec" && args[0] != "--execute"))
{
var b = await StartNoGUI();
Thread mainThread = new Thread(() => NoGUI(b));
mainThread.Start();
return;