Fixed logging

This commit is contained in:
2024-06-08 20:47:15 +03:00
parent d9d5c05313
commit e5e156f371
9 changed files with 109 additions and 11 deletions

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiscordBotCore;
using DiscordBotCore.Interfaces;
using DiscordBotCore.Others;
using DiscordBotCore.Others.Actions;
using DiscordBotCore.Plugin;
namespace DiscordBot.Bot.Actions
{
internal class AddPlugin : ICommandAction
{
public string ActionName => "add-plugin";
public string Description => "Add a local plugin to the database";
public string Usage => "add-plugin <path>";
public IEnumerable<InternalActionOption> ListOfOptions => [
new InternalActionOption("path", "The path to the plugin to add")
];
public InternalActionRunType RunType => InternalActionRunType.ON_CALL;
public async Task Execute(string[] args)
{
if(args.Length < 1)
{
Console.WriteLine("Invalid arguments given. Please use the following format:");
Console.WriteLine("add-plugin <path>");
Console.WriteLine("path: The path to the plugin to add");
return;
}
var path = args[0];
if(!System.IO.File.Exists(path))
{
Console.WriteLine("The file does not exist !!");
return;
}
FileInfo fileInfo = new FileInfo(path);
PluginInfo pluginInfo = new PluginInfo(fileInfo.Name, new(1, 0, 0), [], false, true);
await Application.CurrentApplication.PluginManager.AppendPluginToDatabase(pluginInfo);
}
}
}

View File

@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace DiscordBot;
@@ -81,4 +83,6 @@ public static class Entry
Program.Startup(args).Wait();
}
}

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;
using DiscordBotCore.Others;
using Spectre.Console;
using Spectre.Console.Rendering;