protected override async Task ExecuteAsync(CancellationToken stoppingToken) { _command.AddModule <PartnerModule>(); _provider.GetRequiredService <CommandHandling>(); await _client.LoginAsync(TokenType.Bot, _config["Token"]); await _client.StartAsync(); await Task.Delay(-1, stoppingToken); }
/// <summary> /// Modifies the command. /// </summary> /// <param name="command">The command you want to modify.</param> /// <param name="builder">The modifications you want to make.</param> /// <param name="mBuilder">Modifications you want applied to the <see cref="ModuleBuilder"/> that command belongs.</param> public static void Modify(this Command command, Action <CommandBuilder> builder, Action <ModuleBuilder> mBuilder = null) { Type type = command.GetType(); CommandService commands = command.Service; const string singatureName = "SignatureIdentifier"; FieldInfo field = type.GetField(singatureName, Flags); if (field is null) { throw new QuahuRenamedException(singatureName); } (bool hasRemainder, string signature) = ((bool, string))field.GetValue(command); Module module = command.Module; commands.RemoveModule(module); commands.AddModule(module.Type, moduleBuilder => { mBuilder?.Invoke(moduleBuilder); (bool HasRemainder, string Signature)BuildSignature(CommandBuilder commandBuilder) { var sb = new StringBuilder(); var f = false; for (var i = 0; i < commandBuilder.Parameters.Count; i++) { ParameterBuilder parameter = commandBuilder.Parameters[i]; if (parameter.IsRemainder) { f = true; } sb.Append(parameter.Type).Append(';'); } return(f, sb.ToString()); }
public CommandExecutor() { _service.AddModule <Commands.BaseIRCCommands>(); }