Deleting plugins is now available
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DiscordBot.Utilities;
|
||||
using PluginManager;
|
||||
@@ -71,7 +72,7 @@ internal static class PluginMethods
|
||||
|
||||
if (!pluginData.HasDependencies)
|
||||
{
|
||||
await manager.AppendPluginToDatabase(pluginName, pluginData.Version);
|
||||
await manager.AppendPluginToDatabase(new PluginManager.Plugin.PluginInfo(pluginName, pluginData.Version, []));
|
||||
Console.WriteLine("Finished installing " + pluginName + " successfully");
|
||||
await RefreshPlugins(false);
|
||||
return;
|
||||
@@ -126,7 +127,7 @@ internal static class PluginMethods
|
||||
}
|
||||
);
|
||||
|
||||
await manager.AppendPluginToDatabase(pluginName, pluginData.Version);
|
||||
await manager.AppendPluginToDatabase(new PluginManager.Plugin.PluginInfo(pluginName, pluginData.Version, pluginData.Dependencies.Select(sep => sep.DownloadLocation).ToList()));
|
||||
await RefreshPlugins(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,13 @@ public class Plugin: ICommandAction
|
||||
await PluginMethods.RefreshPlugins(true);
|
||||
break;
|
||||
|
||||
case "uninstall":
|
||||
string plugName = string.Join(' ', args, 1, args.Length-1);
|
||||
bool result = await Config.PluginsManager.MarkPluginToUninstall(plugName);
|
||||
if(result)
|
||||
Console.WriteLine($"Marked to uninstall plugin {plugName}. Please restart the bot");
|
||||
break;
|
||||
|
||||
case "list":
|
||||
await PluginMethods.List(Config.PluginsManager);
|
||||
break;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using PluginManager.UX;
|
||||
|
||||
|
||||
namespace DiscordBot;
|
||||
@@ -13,7 +10,7 @@ public static class Entry
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
#if DEBUG
|
||||
if (args.Length == 1 && args[0] == "/purge_plugins")
|
||||
if (args.Length == 1 && args[0] == "/purge_plugins" )
|
||||
{
|
||||
foreach (var plugin in Directory.GetFiles("./Data/Plugins", "*.dll", SearchOption.AllDirectories))
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using PluginManager;
|
||||
using Spectre.Console;
|
||||
using System.Threading.Tasks;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace DiscordBot;
|
||||
|
||||
@@ -9,15 +9,16 @@ public static class Installer
|
||||
{
|
||||
public static async Task GenerateStartupConfig()
|
||||
{
|
||||
var token = await PluginManager.UX.UxHandler.ShowInputBox("SethBot", "Please enter the bot token:");
|
||||
var botPrefix = await PluginManager.UX.UxHandler.ShowInputBox("SethBot", "Please enter the bot prefix:");
|
||||
var serverId = await PluginManager.UX.UxHandler.ShowInputBox("SethBot", "Please enter the Server ID:");
|
||||
var token = AnsiConsole.Ask<string>("[green]Token:[/]");
|
||||
var botPrefix = AnsiConsole.Ask<string>("[yellow]Prefix:[/]");
|
||||
var serverId = AnsiConsole.Ask<string>("[deeppink1]Server ID:[/]");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(serverId)) serverId = "NULL";
|
||||
if (string.IsNullOrWhiteSpace(serverId)) serverId = string.Empty;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(token) || string.IsNullOrWhiteSpace(botPrefix))
|
||||
{
|
||||
await PluginManager.UX.UxHandler.ShowMessageBox("SethBot", "Invalid token or prefix !", PluginManager.UX.MessageBoxType.Error);
|
||||
AnsiConsole.MarkupLine("Invalid token or prefix !");
|
||||
|
||||
Environment.Exit(-20);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ using DiscordBot.Utilities;
|
||||
using PluginManager.Bot;
|
||||
using PluginManager.Others;
|
||||
using PluginManager.Others.Actions;
|
||||
using PluginManager.UX;
|
||||
using Spectre.Console;
|
||||
using static PluginManager.Config;
|
||||
|
||||
@@ -100,11 +99,6 @@ public class Program
|
||||
{
|
||||
if (ex.Message == "No process is on the other end of the pipe." || (uint)ex.HResult == 0x800700E9)
|
||||
{
|
||||
UxHandler.ShowMessageBox("SethBot", "An error occured while closing the bot last time. Please consider closing the bot using the &rexit&c method !\n" +
|
||||
"There is a risk of losing all data or corruption of the save file, which in some cases requires to reinstall the bot !", MessageBoxType.Error
|
||||
).Wait();
|
||||
|
||||
|
||||
Logger.Log("An error occured while closing the bot last time. Please consider closing the bot using the &rexit&c method !\n" +
|
||||
"There is a risk of losing all data or corruption of the save file, which in some cases requires to reinstall the bot !",
|
||||
typeof(Program), LogType.ERROR
|
||||
@@ -130,7 +124,6 @@ public class Program
|
||||
|
||||
if (logMessage.Message.Contains('['))
|
||||
{
|
||||
// If the message contains a tag, just print it as it is. No need to format it
|
||||
Console.WriteLine(logMessage.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user