using System; using System.Net.Http; using Autofac; using DSharpPlus; using PluralKit.Core; using Sentry; namespace PluralKit.Bot { public class BotModule: Module { protected override void Load(ContainerBuilder builder) { // Clients builder.Register(c => new DiscordConfiguration { Token = c.Resolve().Token, TokenType = TokenType.Bot, MessageCacheSize = 0, LargeThreshold = 50 }).AsSelf(); builder.Register(c => new DiscordShardedClient(c.Resolve())).AsSelf().SingleInstance(); builder.Register(c => new DiscordRestClient(c.Resolve())).AsSelf().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(); } } }