public CommandHandler(IServiceProvider services) { _config = services.GetRequiredService <AssistantConfig>(); _client = services.GetRequiredService <DiscordSocketClient>(); _logger = services.GetRequiredService <LoggingService>(); _commands = services.GetRequiredService <CommandService>(); _services = services; }
public Assistant(AssistantConfig config) { DiscordSocketConfig clientConfig = new DiscordSocketConfig { LogLevel = config.Log?.Severity ?? LoggingService.DefaultSeverity }; _config = config; _client = new DiscordSocketClient(); _services = new ServiceCollection() .AddSingleton(_config) .AddSingleton(_client) .AddSingleton(new CommandService(new CommandServiceConfig { DefaultRunMode = RunMode.Async })) .AddSingleton <Random>() .AddSingleton <HttpService>() .AddSingleton <CommandHandler>() .AddSingleton <LoggingService>() .AddSingleton <IInitializable>(s => s.GetRequiredService <CommandHandler>()) .AddSingleton <IInitializable>(s => s.GetRequiredService <LoggingService>()) .BuildServiceProvider(); }
private static Task Main(string[] args) => new Assistant(AssistantConfig.FromFile("config.json")).StartAndBlock();
public LoggingService(DiscordSocketClient client, AssistantConfig config) : this(client, config.Log) { }