예제 #1
0
        public async Task MainAsync()
        {
            _client = new DiscordSocketClient(new DiscordSocketConfig
            {
                AlwaysDownloadUsers = true,
                MessageCacheSize    = 10000,
                GatewayIntents      = GatewayIntents.Guilds | GatewayIntents.GuildMessages | GatewayIntents.GuildMessageReactions | GatewayIntents.GuildPresences | GatewayIntents.GuildVoiceStates | GatewayIntents.GuildMembers | GatewayIntents.GuildPresences,
                LogLevel            = LogSeverity.Info
            });


            // build or create config
            ConfigTools configBuilder = new ConfigTools();

            _config = configBuilder.Build();

            // Download required files from my server
            PrerequisiteFilesDownloader.StartupCheck();

            var services = ConfigureServices();

            services.GetRequiredService <LogService>();
            await services.GetRequiredService <CommandHandlingService>().InitializeAsync(services);

            services.GetRequiredService <DatabaseService>().Initialize();
            services.GetRequiredService <ServerPreferenceService>().Initialize();
            services.GetRequiredService <SpotifyService>().Initialize();



            _lavaNode = services.GetRequiredService <LavaNode>();

            if (_config["token"] == "insert token here")
            {
                Console.WriteLine("NO TOKEN SET IN CONFIG FILE");
                Environment.Exit(0);
            }

            // log in the bot with the supplied bot token
            await _client.LoginAsync(TokenType.Bot, _config["token"]);

            await _client.StartAsync();

            _client.Ready += OnClientReady;

            await Task.Delay(-1);
        }