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