// Base Methods public async Task LoadAsync() { Rest = new DiscordRestClient(new DiscordRestConfig { DefaultRetryMode = RetryMode.AlwaysRetry, LogLevel = LoadConfig.LogLevel }); Socket = new DiscordSocketClient(new DiscordSocketConfig { DefaultRetryMode = RetryMode.AlwaysRetry, LogLevel = LoadConfig.LogLevel }); Commands = new CommandService(new CommandServiceConfig { IgnoreExtraArgs = true, DefaultRunMode = RunMode.Sync, CaseSensitiveCommands = false, LogLevel = LoadConfig.LogLevel }); var collection = new ServiceCollection(); collection.AddSingleton(Rest) .AddSingleton(Socket) .AddSingleton(Commands) .AddSingleton(this); Configuration = new Configuration(LoadConfig.Database); collection.AddSingleton(Configuration); IServices.AddRange(new ReputationService(LoadConfig), new GiveawayService(Configuration), new RotatingStatusService(Socket), new ReputationService(LoadConfig)); foreach (var service in IServices) { DisconnectList[service.GetType()] = false; collection.AddSingleton(service.GetType(), service); } Services = collection.BuildServiceProvider(); Commands.AddTypeReader(typeof(IUser), new UserTypeReader()); Commands.AddTypeReader(typeof(TimeSpan), new TimeSpanTypeReader()); Commands.AddTypeReader(typeof(IEmote), new IEmoteTypeReader()); Commands.AddTypeReader(typeof(Emoji), new EmojiTypeReader()); Commands.AddTypeReader(typeof(Emote), new EmoteTypeReader()); await Commands.AddModulesAsync(Assembly.GetEntryAssembly(), Services); Socket.Ready += Ready; Socket.MessageReceived += HandleCommandsAsync; Socket.MessageReceived += HandleMessagesAsync; Rest.Log += Log; Socket.Log += Log; Commands.Log += Log; var wglb = DependencyInjection.CreateInjected <WGLBMessages>(Services); Socket.UserJoined += wglb.GreetingsAsync; Socket.UserJoined += wglb.WelcomeAsync; Socket.UserLeft += wglb.LeaveAsync; Socket.UserBanned += wglb.BanAsync; var autoroles = DependencyInjection.CreateInjected <AutoRoleModule>(Services); Socket.UserJoined += autoroles.AutoRoleAsync; OnConsoleInput += ConsoleCommand; AppDomain.CurrentDomain.ProcessExit += async(sender, eventArgs) => { if (Socket.ConnectionState == ConnectionState.Connected) { await StopAsync(false); await UnloadAsync(); } }; }