public virtual bool TryFindCommand(IMessageEvent e, out IVersaCommand command, out string matchedCommandText) { foreach (var comG in e.EventSpecificCommands.Concat(Groups)) { if (!comG.TryFindCommand(GlobalPrefix, e, out command, out matchedCommandText)) { continue; } RunStateArgs.OnNext(new CommandRunStateEventArgs(e, command, null, ECommandState.FoundCommand)); return(true); } command = default; matchedCommandText = default; return(false); }
public virtual async Task <(bool, Task <(bool, IConditionalRule, string)>)> RunSupportedCommand( IMessageEvent @event, IVersaCommand command, string matchedCommandLine) { switch (command) { case IVersaCommand <CommandContext> basicCommand: RunStateArgs.OnNext(new CommandRunStateEventArgs(@event, command, null, ECommandState.BeforeContextConstruction)); var factory = @event.Services .GetRequiredService <ICommandContextFactory <CommandContext> >(); var(context, additionalConditionFuncs) = await factory.ConfigureContextAsync(@event, basicCommand, matchedCommandLine).ConfigureAwait(false); return(true, RunCommand(@event, context, basicCommand, @event.Services, additionalConditionFuncs)); default: return(false, default); } }