private async Task StartBot(string oauthToken) { var botChatAuthenticated = Twitch.AuthenticateBot() .FromOAuthToken(oauthToken) .Build(); _chatBot = new TwitchChatBot(botChatAuthenticated, _appClient, ServiceProvider, ServiceProvider.GetRequiredService <ILogger <TwitchChatBot> >()); var orleansTaskScheduler = TaskScheduler.Current; _botCancellationSource = new CancellationTokenSource(); var cancellationToken = _botCancellationSource.Token; _botTask = Task.Run(() => _chatBot.StartAsync(cancellationToken)); _chatBot.SetChannel(_channelId); foreach ((var key, var processorInfo) in _channelBotState.State.Commands) { var registration = _registeredCommands[processorInfo.Type]; await _chatBot.RegisterMessageProcessor(registration.ProcessorType, processorInfo); } }