private (Command <TestContext>, ParsedCommand) MatchCommand(string commandText)
        {
            var parsedCommand = _parser.ParseContext(new TestContext {
                Message = commandText
            }, 1);
            var modules = GetModules();

            return(_matcher.MatchCommand(modules, parsedCommand), parsedCommand);
        }
Exemple #2
0
 /// <summary>
 /// Processes a context generated from whatever service you are providing commands for.
 /// It will parse the message, check if it is a command, find the correct command and execute it.
 /// </summary>
 /// <param name="ctx">The context created by you from a message from the service you're providing commands for.</param>
 public async Task ProcessMessageAsync(TContext ctx)
 {
     if (ctx.Message.StartsWith(Prefix))
     {
         var parsedCommand = Parser.ParseContext(ctx, PrefixLength);
         var commandMatch  = _matcher.MatchCommand(RegisteredModules, parsedCommand);
         var result        = _execution.ExecuteCommand(commandMatch, parsedCommand);
         await result.Item1;
         OnCommandExecuted?.Invoke(this, result.Item2);
     }
 }