diff --git a/BUILDS/net6.0/EVE_LevelingSystem.dll b/BUILDS/net6.0/EVE_LevelingSystem.dll index 81fecad..e443461 100644 Binary files a/BUILDS/net6.0/EVE_LevelingSystem.dll and b/BUILDS/net6.0/EVE_LevelingSystem.dll differ diff --git a/BUILDS/net6.0/PluginManager.dll b/BUILDS/net6.0/PluginManager.dll index 64b47fa..856115d 100644 Binary files a/BUILDS/net6.0/PluginManager.dll and b/BUILDS/net6.0/PluginManager.dll differ diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs index 73e4005..9c1a719 100644 --- a/DiscordBot/Program.cs +++ b/DiscordBot/Program.cs @@ -87,7 +87,8 @@ namespace DiscordBot while (true) { Console.ForegroundColor = ConsoleColor.White; - consoleCommandsHandler.HandleCommand(Console.ReadLine()); + string cmd = Console.ReadLine(); + consoleCommandsHandler.HandleCommand(cmd); } } diff --git a/EVE_LevelingSystem/LevelingSystem.cs b/EVE_LevelingSystem/LevelingSystem.cs index 7f7195b..9325e4d 100644 --- a/EVE_LevelingSystem/LevelingSystem.cs +++ b/EVE_LevelingSystem/LevelingSystem.cs @@ -5,6 +5,9 @@ using Discord.WebSocket; using PluginManager.Others; using PluginManager.Interfaces; using PluginManager.LanguageSystem; +using PluginManager.Items; +using System; + public class LevelingSystem : DBEvent { public string name => "Leveling System"; @@ -13,6 +16,13 @@ public class LevelingSystem : DBEvent public void Start(DiscordSocketClient client) { + + ConsoleCommandsHandler.AddCommand("lvl", "calos command extern", async (args) => + { + Console.WriteLine("Leveling system command"); + + }); + client.MessageReceived += Client_MessageReceived; } diff --git a/FreeGames/Game.cs b/FreeGames/Game.cs index 40753fd..7080383 100644 --- a/FreeGames/Game.cs +++ b/FreeGames/Game.cs @@ -1,5 +1,8 @@ using PluginManager.Interfaces; +using PluginManager.Items; using Games.Objects; +using PluginManager.Others; + namespace Games; public class Game : DBCommand @@ -15,7 +18,8 @@ public class Game : DBCommand public async void Execute(Discord.Commands.SocketCommandContext context, Discord.WebSocket.SocketMessage message, Discord.WebSocket.DiscordSocketClient client, bool isDM) { - string game_name = PluginManager.Others.Functions.MergeStrings(message.Content.Split(' '), 1); + + string game_name = Functions.MergeStrings(message.Content.Split(' '), 1); string game_url = await GameData.GetSteamLinkFromGame(game_name); if (game_url is null || game_url == null) { diff --git a/PluginManager/Items/ConsoleCommandsHandler.cs b/PluginManager/Items/ConsoleCommandsHandler.cs index 39293ac..30a8c7a 100644 --- a/PluginManager/Items/ConsoleCommandsHandler.cs +++ b/PluginManager/Items/ConsoleCommandsHandler.cs @@ -11,6 +11,8 @@ using System.Diagnostics; using System.Threading.Tasks; using System.Threading; using PluginManager.LanguageSystem; +using System.Linq; +using System.Reflection.Metadata.Ecma335; namespace PluginManager.Items { @@ -21,25 +23,25 @@ namespace PluginManager.Items private static LanguageManager languageManager = new LanguageManager("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Languages"); - public static List>> commandList = new List>>(); + public static List>>? commandList = new List>>(); private DiscordSocketClient client; public ConsoleCommandsHandler(DiscordSocketClient client) { this.client = client; - //commandList = new List>>(); InitializeBasicCommands(); - //Console.WriteLine("ConsoleCommandsHandler enabled"); + Console.WriteLine("Initalized console command handeler !"); } private void InitializeBasicCommands() { bool pluginsLoaded = false; + commandList.Clear(); AddCommand("help", "Show help", (args) => { - if (args.Length == 1) + if (args.Length <= 1) { Console.WriteLine("Available commands:"); foreach (var command in commandList) @@ -51,7 +53,7 @@ namespace PluginManager.Items { foreach (var command in commandList) { - if (command.Item1 == args[0]) + if (command.Item1 == args[1]) { Console.WriteLine(command.Item2); return; @@ -270,20 +272,20 @@ namespace PluginManager.Items else Console.WriteLine("File could not be found. Please register token"); }); + + } public static void AddCommand(string command, string description, Action action) { commandList.Add(new Tuple>(command, description, action)); + Console.ForegroundColor = ConsoleColor.White; Console_Utilities.WriteColorText($"Command &r{command} &cadded to the list of commands"); } public static void AddCommand(string command, string description, Action action) { - AddCommand(command, description, (args) => - { - action(); - }); + AddCommand(command, description, (args) => action()); /* Console.WriteLine("Added command: " + command);*/ } @@ -293,15 +295,20 @@ namespace PluginManager.Items commandList.RemoveAll(x => x.Item1 == command); } + public static Tuple>? SearchCommand(string command) + { + return commandList.FirstOrDefault(t => t.Item1 == command); + } + public void HandleCommand(string command) { string[] args = command.Split(' '); - foreach (var item in commandList) + foreach (var item in commandList.ToList()) { if (item.Item1 == args[0]) { item.Item3(args); - return; + //Console.WriteLine($"Executing: {args[0]} with the following parameters: {args.MergeStrings(1)}"); } } }