diff --git a/BUILDS/net6.0/StartupEvents.dll b/BUILDS/net6.0/StartupEvents.dll index 49ec2e1..c289609 100644 Binary files a/BUILDS/net6.0/StartupEvents.dll and b/BUILDS/net6.0/StartupEvents.dll differ diff --git a/DiscordBot/Discord/Commands/Restart.cs b/DiscordBot/Discord/Commands/Restart.cs index b88936e..3808118 100644 --- a/DiscordBot/Discord/Commands/Restart.cs +++ b/DiscordBot/Discord/Commands/Restart.cs @@ -53,7 +53,7 @@ namespace DiscordBot.Discord.Commands { if (!DiscordPermissions.hasPermission(message.Author as SocketGuildUser, DiscordLib.GuildPermission.Administrator)) return; var args = Functions.GetArguments(message); - var OS = Functions.GetOperatinSystem(); + var OS = Functions.GetOperatingSystem(); if (args.Count == 0) { switch (OS) @@ -94,7 +94,7 @@ namespace DiscordBot.Discord.Commands Process.Start("./DiscordBot.exe", cmd); break; case PluginManager.Others.OperatingSystem.LINUX: - case PluginManager.Others.OperatingSystem.MAC_OS: + //case PluginManager.Others.OperatingSystem.MAC_OS: ?? - not tested Process.Start("./DiscordBot", cmd); break; default: diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs index 8bc41b1..91d63a5 100644 --- a/DiscordBot/Program.cs +++ b/DiscordBot/Program.cs @@ -85,6 +85,7 @@ namespace DiscordBot if (listLanguagAtStartup) await languageManager.ListAllLanguages(); + Console_Utilities.ProgressBar pbar; IProgress progress = null; Task t; @@ -94,7 +95,7 @@ namespace DiscordBot while (true) { Console.ForegroundColor = ConsoleColor.White; - Console_Utilities.WriteColorText("&mConsole > &c", false); + Console_Utilities.WriteColorText("&mConsole ", false); string[] data = Console.ReadLine().Split(' '); if (data[0].Length < 2) @@ -150,7 +151,7 @@ namespace DiscordBot if (info.Length == 3 && info[2] != string.Empty && info[2] != null) { Console.WriteLine($"Downloading requirements for plugin : {name}"); - // + List lines = await ServerCom.ReadTextFromFile(info[2]); int i = 1; @@ -172,6 +173,7 @@ namespace DiscordBot case "setlang": if (data.Length == 2) SetLanguage(data[1]); + else Console.WriteLine("Invalid arguments"); break; case "set-setting": if (data.Length >= 3) @@ -230,7 +232,8 @@ namespace DiscordBot break; case "help": Console.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine( + Console.WriteLine + ( "lp | loadplugins -> load all plugins\n" + "sd | shutdown->close connection to the server(stop bot)\n" + "token -> display the current token\n" + @@ -308,7 +311,7 @@ namespace DiscordBot //Load language from the specified file ... Language.ActiveLanguage = null; - string langname = File.ReadAllText(langSettings).Split('=')[1]; + string langname = Functions.readCodeFromFile(langSettings, "Language", '='); if (langname == "English") { Language.ActiveLanguage = null; diff --git a/PluginManager/Online/PluginsManager.cs b/PluginManager/Online/PluginsManager.cs index 344d3fd..1e7a7e6 100644 --- a/PluginManager/Online/PluginsManager.cs +++ b/PluginManager/Online/PluginsManager.cs @@ -36,7 +36,7 @@ namespace PluginManager.Online string[] lines = list.ToArray(); List data = new List(); - var op = Functions.GetOperatinSystem(); + var op = Functions.GetOperatingSystem(); int len = lines.Length; string[] titles = { "Name", "Description", "Plugin Type", "Libraries" }; diff --git a/PluginManager/Others/Console Utilities.cs b/PluginManager/Others/Console Utilities.cs index 2d2cbf6..1cdf29a 100644 --- a/PluginManager/Others/Console Utilities.cs +++ b/PluginManager/Others/Console Utilities.cs @@ -62,15 +62,6 @@ namespace PluginManager.Others else Console.Write(progress.ToString() + $"{speed} {unit}/s "); - //if (r == false) - //Update(progress, true); - - } - - public void Finish() - { - Console.Write("\r{0} {1}%", Message, 100); - Console.WriteLine(); } } @@ -132,13 +123,9 @@ namespace PluginManager.Others } } - /// - /// Write text using colors: &g - green, &r - red, &b - blue, &m - magenta, &c - Clear - /// - /// - /// public static void WriteColorText(string text, bool appendNewLine = true) { + string[] words = text.Split(' '); ConsoleColor fg = Console.ForegroundColor; Dictionary colors = new Dictionary() diff --git a/PluginManager/Others/Enums.cs b/PluginManager/Others/Enums.cs index 5413955..222e169 100644 --- a/PluginManager/Others/Enums.cs +++ b/PluginManager/Others/Enums.cs @@ -11,7 +11,7 @@ /// A list with all errors /// public enum Error - { UNKNOWN_ERROR, GUILD_NOT_FOUND, STREAM_NOT_FOUND } + { UNKNOWN_ERROR, GUILD_NOT_FOUND, STREAM_NOT_FOUND, INVALID_USER, INVALID_CHANNEL, INVALID_PERMISSIONS } /// /// The output log type diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs index 7c5de71..a2a7d5a 100644 --- a/PluginManager/Others/Functions.cs +++ b/PluginManager/Others/Functions.cs @@ -162,7 +162,7 @@ namespace PluginManager.Others /// Get the Operating system you are runnin on /// /// An Operating system - public static OperatingSystem GetOperatinSystem() + public static OperatingSystem GetOperatingSystem() { if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) return OperatingSystem.WINDOWS; if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)) return OperatingSystem.LINUX; diff --git a/StartupEvents/OnUserJoin.cs b/StartupEvents/OnUserJoin.cs index 10fbbe1..bb4ff5f 100644 --- a/StartupEvents/OnUserJoin.cs +++ b/StartupEvents/OnUserJoin.cs @@ -14,8 +14,6 @@ public class OnUserJoin : DBEvent public async void Start(Discord.WebSocket.DiscordSocketClient client) { - - System.IO.Directory.CreateDirectory(UtilsPath); if (!System.IO.File.Exists(ConfigFile)) @@ -36,7 +34,7 @@ public class OnUserJoin : DBEvent } if (Functions.readCodeFromFile(ConfigFile, "Enabled", '=') != "True") return; - System.Console.WriteLine("Awaiting user join event ..."); + //System.Console.WriteLine("Awaiting user join event ..."); client.UserJoined += Client_UserJoined; diff --git a/TODO b/TODO new file mode 100644 index 0000000..50534d2 --- /dev/null +++ b/TODO @@ -0,0 +1,27 @@ +Discord Bot: + ✔ Create bootloader + ✔ Create commands handler + +Plugin Manager: + Define plugin interface: + ✔ DBCommand + ✔ DBPlugin + + Functions.cs: + ✔ Read from file + ✔ Read from archive (PAK) + ✔ Write Logs & Errors + ✔ Manipulate settings (files) and strings + ✔ Stream copy async + + Console Utilities: + ✔ Progress bar + ✔ Create table + ✔ Write to console with colors + + Discord Permissions: + ✔ Check if user has permission + ✔ Check if user is owner + + + \ No newline at end of file