From 9c3bb5b969cdf8c5bd75b7bfd187a0f5498c035e Mon Sep 17 00:00:00 2001 From: Tides Date: Sat, 24 Feb 2024 02:42:36 -0500 Subject: [PATCH] Update Command.cs --- Obsidian/Commands/Framework/Entities/Command.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Obsidian/Commands/Framework/Entities/Command.cs b/Obsidian/Commands/Framework/Entities/Command.cs index 942d27a9e..61bd5906f 100644 --- a/Obsidian/Commands/Framework/Entities/Command.cs +++ b/Obsidian/Commands/Framework/Entities/Command.cs @@ -88,7 +88,7 @@ public async Task ExecuteAsync(CommandContext context, string[] args) } private bool TryFindExecutor(IEnumerable> executors, string[] args, CommandContext context, - [NotNullWhen(true)]out IExecutor? executor) + [NotNullWhen(true)] out IExecutor? executor) { executor = null; @@ -102,8 +102,6 @@ private bool TryFindExecutor(IEnumerable> executors, s foreach (var exec in executors) { - executor = exec; - var methodParams = exec.GetParameters(); for (int i = 0; i < args.Length; i++) { @@ -111,11 +109,7 @@ private bool TryFindExecutor(IEnumerable> executors, s var arg = args[i]; if (!CommandHandler.IsValidArgumentType(param.ParameterType)) - { - success = false; - executor = null; return false; - } var parser = CommandHandler.GetArgumentParser(param.ParameterType); if (parser.TryParseArgument(arg, context, out _)) @@ -124,12 +118,14 @@ private bool TryFindExecutor(IEnumerable> executors, s continue; } - success = false; return false; } if (success) + { + executor = exec; return true; + } } return false;