コード例 #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await InitializeHandlers();

            RegisterHandlers();

            await _client.LoginAsync(TokenType.Bot, _discordConfiguration.Token);

            await _client.StartAsync();

            while (!stoppingToken.IsCancellationRequested)
            {
                // _logger.LogInformation("DiscordClientWorker running at: {time}", DateTimeOffset.Now);
                await Task.Delay(1000, stoppingToken);
            }

            _logger.LogInformation($"DiscordClientWorker task is stopping");

            await _client.StopAsync();
        }