Ejemplo n.º 1
0
        public async Task MainAsync()
        {
            // You should dispose a service provider created using ASP.NET
            // when you are finished using it, at the end of your app's lifetime.
            // If you use another dependency injection framework, you should inspect
            // its documentation for the best way to do this.
            using (var services = ConfigureServices())
            {
                var client = services.GetRequiredService <DiscordSocketClient>();

                client.Log += LogAsync;
                services.GetRequiredService <CommandService>().Log += LogAsync;

                // Tokens should be considered secret data and never hard-coded.
                // We can read from the environment variable to avoid hardcoding.
                await client.LoginAsync(TokenType.Bot, RedisStore.GetSecret("KK2_BOT"));

                await client.StartAsync();

                // Here we initialize the logic required to register our commands.
                await services.GetRequiredService <CommandHandlingService>().InitializeAsync();

                await Task.Delay(Timeout.Infinite);
            }
        }