示例#1
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                LogStartup();
                await commandService.AddModulesAsync();

                client = new DiscordSocketClient();
                string token = botConfig.Token;
                await client.LoginAsync(TokenType.Bot, token);

                await client.StartAsync();

                client.MessageReceived += HandleMessageReceived;
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "There was an unhandled exception during startup.");
                await StopAsync(cancellationToken);
            }
        }