plugin list command now shows if the plugin is already installed.
This commit is contained in:
@@ -9,19 +9,19 @@ namespace PluginManager.Others.Actions;
|
||||
public class InternalActionManager
|
||||
{
|
||||
public Dictionary<string, ICommandAction> Actions = new();
|
||||
public ActionsLoader loader;
|
||||
private readonly ActionsLoader _loader;
|
||||
|
||||
public InternalActionManager(string path, string extension)
|
||||
{
|
||||
loader = new ActionsLoader(path, extension);
|
||||
_loader = new ActionsLoader(path, extension);
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
{
|
||||
var m_actions = await loader.Load();
|
||||
if (m_actions == null)
|
||||
var loadedActions = await _loader.Load();
|
||||
if (loadedActions == null)
|
||||
return;
|
||||
foreach (var action in m_actions)
|
||||
foreach (var action in loadedActions)
|
||||
Actions.TryAdd(action.ActionName, action);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,27 +8,9 @@ namespace PluginManager.Others;
|
||||
|
||||
public static class ArchiveManager
|
||||
{
|
||||
private static string? _ArchiveFolder;
|
||||
private static bool IsInitialized { get; set; }
|
||||
|
||||
public static void Initialize()
|
||||
public static void CreateFromFile(string file, string folder)
|
||||
{
|
||||
if (IsInitialized)
|
||||
throw new Exception("ArchiveManager is already initialized");
|
||||
|
||||
if (!Config.AppSettings.ContainsKey("ArchiveFolder"))
|
||||
Config.AppSettings["ArchiveFolder"] = "./Data/Archives/";
|
||||
|
||||
_ArchiveFolder = Config.AppSettings["ArchiveFolder"];
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
public static async Task CreateFromFile(string file, string folder)
|
||||
{
|
||||
if(!IsInitialized) throw new Exception("ArchiveManager is not initialized");
|
||||
|
||||
if (!Directory.Exists(folder))
|
||||
Directory.CreateDirectory(folder);
|
||||
|
||||
@@ -50,9 +32,8 @@ public static class ArchiveManager
|
||||
/// <returns>An array of bytes that represents the Stream value from the file that was read inside the archive</returns>
|
||||
public static async Task<byte[]?> ReadStreamFromPakAsync(string fileName, string archName)
|
||||
{
|
||||
if (!IsInitialized) throw new Exception("ArchiveManager is not initialized");
|
||||
|
||||
archName = _ArchiveFolder + archName;
|
||||
archName = Config.AppSettings["ArchiveFolder"] + archName;
|
||||
|
||||
if (!File.Exists(archName))
|
||||
throw new Exception("Failed to load file !");
|
||||
@@ -80,8 +61,7 @@ public static class ArchiveManager
|
||||
/// <returns>A string that represents the content of the file or null if the file does not exists or it has no content</returns>
|
||||
public static async Task<string?> ReadFromPakAsync(string fileName, string archFile)
|
||||
{
|
||||
if (!IsInitialized) throw new Exception("ArchiveManager is not initialized");
|
||||
archFile = _ArchiveFolder + archFile;
|
||||
archFile = Config.AppSettings["ArchiveFolder"] + archFile;
|
||||
if (!File.Exists(archFile))
|
||||
throw new Exception("Failed to load file !");
|
||||
|
||||
@@ -125,7 +105,6 @@ public static class ArchiveManager
|
||||
string zip, string folder, IProgress<float> progress,
|
||||
UnzipProgressType type)
|
||||
{
|
||||
if (!IsInitialized) throw new Exception("ArchiveManager is not initialized");
|
||||
Directory.CreateDirectory(folder);
|
||||
using var archive = ZipFile.OpenRead(zip);
|
||||
var totalZipFiles = archive.Entries.Count();
|
||||
|
||||
@@ -6,6 +6,13 @@ namespace PluginManager.Others;
|
||||
|
||||
public class DbCommandExecutingArguments
|
||||
{
|
||||
|
||||
public SocketCommandContext context { get; init; }
|
||||
public string cleanContent { get; init; }
|
||||
public string commandUsed { get; init; }
|
||||
public string[]? arguments { get; init; }
|
||||
public ISocketMessageChannel Channel => context.Channel;
|
||||
|
||||
public DbCommandExecutingArguments(
|
||||
SocketCommandContext context, string cleanContent, string commandUsed, string[]? arguments)
|
||||
{
|
||||
@@ -26,7 +33,7 @@ public class DbCommandExecutingArguments
|
||||
}
|
||||
else
|
||||
{
|
||||
cleanContent = message.Content.Substring(Config.DiscordBot.botPrefix.Length);
|
||||
cleanContent = message.Content.Substring(Config.DiscordBot.BotPrefix.Length);
|
||||
}
|
||||
|
||||
var split = cleanContent.Split(' ');
|
||||
@@ -38,10 +45,4 @@ public class DbCommandExecutingArguments
|
||||
commandUsed = split[0];
|
||||
arguments = argsClean;
|
||||
}
|
||||
|
||||
public SocketCommandContext context { get; init; }
|
||||
public string cleanContent { get; init; }
|
||||
public string commandUsed { get; init; }
|
||||
public string[]? arguments { get; init; }
|
||||
public ISocketMessageChannel Channel => context.Channel;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,6 @@ public enum UnzipProgressType
|
||||
PERCENTAGE_FROM_TOTAL_SIZE
|
||||
}
|
||||
|
||||
public enum SaveType
|
||||
{
|
||||
TXT,
|
||||
JSON
|
||||
}
|
||||
|
||||
public enum InternalActionRunType
|
||||
{
|
||||
ON_STARTUP,
|
||||
|
||||
@@ -26,7 +26,7 @@ public static class DiscordPermissions
|
||||
/// <param name="user">The user</param>
|
||||
/// <param name="role">The role</param>
|
||||
/// <returns></returns>
|
||||
public static bool hasRole(this SocketGuildUser user, IRole role)
|
||||
public static bool HasRole(this SocketGuildUser user, IRole role)
|
||||
{
|
||||
return user.Roles.Contains(role);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public static class DiscordPermissions
|
||||
/// <param name="user">The user</param>
|
||||
/// <param name="permission">The permission</param>
|
||||
/// <returns></returns>
|
||||
public static bool hasPermission(this SocketGuildUser user, GuildPermission permission)
|
||||
public static bool HasPermission(this SocketGuildUser user, GuildPermission permission)
|
||||
{
|
||||
return user.Roles.Where(role => role.hasPermission(permission)).Any() || user.Guild.Owner == user;
|
||||
}
|
||||
@@ -47,9 +47,9 @@ public static class DiscordPermissions
|
||||
/// </summary>
|
||||
/// <param name="user">The user</param>
|
||||
/// <returns></returns>
|
||||
public static bool isAdmin(this SocketGuildUser user)
|
||||
public static bool IsAdmin(this SocketGuildUser user)
|
||||
{
|
||||
return user.hasPermission(GuildPermission.Administrator);
|
||||
return user.HasPermission(GuildPermission.Administrator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,8 +57,8 @@ public static class DiscordPermissions
|
||||
/// </summary>
|
||||
/// <param name="user">The user</param>
|
||||
/// <returns></returns>
|
||||
public static bool isAdmin(this SocketUser user)
|
||||
public static bool IsAdmin(this SocketUser user)
|
||||
{
|
||||
return isAdmin((SocketGuildUser)user);
|
||||
return IsAdmin((SocketGuildUser)user);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user