Factor DiscordConfiguration out into DI

This commit is contained in:
Ske 2020-04-29 00:05:26 +02:00
parent 35e30f481b
commit 9b6f79a508

View File

@ -16,18 +16,15 @@ namespace PluralKit.Bot
protected override void Load(ContainerBuilder builder) protected override void Load(ContainerBuilder builder)
{ {
// Clients // Clients
builder.Register(c => new DiscordShardedClient(new DiscordConfiguration builder.Register(c => new DiscordConfiguration
{ {
Token = c.Resolve<BotConfig>().Token, Token = c.Resolve<BotConfig>().Token,
TokenType = TokenType.Bot, TokenType = TokenType.Bot,
MessageCacheSize = 0, MessageCacheSize = 0,
})).AsSelf().SingleInstance(); LargeThreshold = 50
builder.Register(c => new DiscordRestClient(new DiscordConfiguration }).AsSelf();
{ builder.Register(c => new DiscordShardedClient(c.Resolve<DiscordConfiguration>())).AsSelf().SingleInstance();
Token = c.Resolve<BotConfig>().Token, builder.Register(c => new DiscordRestClient(c.Resolve<DiscordConfiguration>())).AsSelf().SingleInstance();
TokenType = TokenType.Bot,
MessageCacheSize = 0,
})).AsSelf().SingleInstance();
// Commands // Commands
builder.RegisterType<CommandTree>().AsSelf(); builder.RegisterType<CommandTree>().AsSelf();
@ -70,7 +67,6 @@ namespace PluralKit.Bot
// Sentry stuff // Sentry stuff
builder.Register(_ => new Scope(null)).AsSelf().InstancePerLifetimeScope(); builder.Register(_ => new Scope(null)).AsSelf().InstancePerLifetimeScope();
// Utils // Utils
builder.Register(c => new HttpClient builder.Register(c => new HttpClient
{ {