using System; using System.Net.Http; using Autofac; using Discord; using Discord.Rest; using Discord.WebSocket; using PluralKit.Core; using Sentry; namespace PluralKit.Bot { public class BotModule: Module { protected override void Load(ContainerBuilder builder) { // Client builder.Register(c => new DiscordShardedClient(new DiscordSocketConfig() { MessageCacheSize = 0, ConnectionTimeout = 2 * 60 * 1000, ExclusiveBulkDelete = true, LargeThreshold = 50, GuildSubscriptions = false, DefaultRetryMode = RetryMode.RetryTimeouts | RetryMode.RetryRatelimit // Commented this out since Debug actually sends, uh, quite a lot that's not necessary in production // but leaving it here in case I (or someone else) get[s] confused about why logging isn't working again :p // LogLevel = LogSeverity.Debug // We filter log levels in Serilog, so just pass everything through (Debug is lower than Verbose) })).AsSelf().As().As().As().SingleInstance(); // Commands builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); builder.RegisterType().AsSelf(); // Bot core builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf(); // Bot services builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); // Sentry stuff builder.Register(_ => new Scope(null)).AsSelf().InstancePerLifetimeScope(); // Utils builder.Register(c => new HttpClient { Timeout = TimeSpan.FromSeconds(5) }).AsSelf().SingleInstance(); } } }