PluralKit/PluralKit.Bot/Modules.cs

75 lines
3.1 KiB
C#
Raw Normal View History

2020-01-26 00:27:45 +00:00
using System;
using System.Net.Http;
using Autofac;
using DSharpPlus;
2020-01-26 00:27:45 +00:00
using PluralKit.Core;
2020-01-26 00:27:45 +00:00
using Sentry;
namespace PluralKit.Bot
{
public class BotModule: Module
{
protected override void Load(ContainerBuilder builder)
{
// Client
builder.Register(c => new DiscordShardedClient(new DiscordConfiguration
{
Token = c.Resolve<BotConfig>().Token,
TokenType = TokenType.Bot,
MessageCacheSize = 0,
})).AsSelf().SingleInstance();
2020-01-26 00:27:45 +00:00
// Commands
builder.RegisterType<CommandTree>().AsSelf();
2020-02-01 12:03:02 +00:00
builder.RegisterType<Autoproxy>().AsSelf();
builder.RegisterType<Fun>().AsSelf();
builder.RegisterType<Help>().AsSelf();
builder.RegisterType<ImportExport>().AsSelf();
builder.RegisterType<Member>().AsSelf();
builder.RegisterType<MemberAvatar>().AsSelf();
builder.RegisterType<MemberEdit>().AsSelf();
builder.RegisterType<MemberProxy>().AsSelf();
builder.RegisterType<Misc>().AsSelf();
builder.RegisterType<ServerConfig>().AsSelf();
builder.RegisterType<Switch>().AsSelf();
builder.RegisterType<System>().AsSelf();
2020-02-01 12:03:02 +00:00
builder.RegisterType<SystemEdit>().AsSelf();
builder.RegisterType<SystemFront>().AsSelf();
builder.RegisterType<SystemLink>().AsSelf();
builder.RegisterType<SystemList>().AsSelf();
builder.RegisterType<Token>().AsSelf();
2020-01-26 00:27:45 +00:00
// Bot core
builder.RegisterType<Bot>().AsSelf().SingleInstance();
builder.RegisterType<PKEventHandler>().AsSelf();
// Bot services
builder.RegisterType<EmbedService>().AsSelf().SingleInstance();
builder.RegisterType<ProxyService>().AsSelf().SingleInstance();
builder.RegisterType<LogChannelService>().AsSelf().SingleInstance();
builder.RegisterType<DataFileService>().AsSelf().SingleInstance();
2020-03-26 23:01:42 +00:00
builder.RegisterType<WebhookRateLimitService>().AsSelf().SingleInstance();
2020-01-26 00:27:45 +00:00
builder.RegisterType<WebhookExecutorService>().AsSelf().SingleInstance();
builder.RegisterType<WebhookCacheService>().AsSelf().SingleInstance();
builder.RegisterType<ShardInfoService>().AsSelf().SingleInstance();
builder.RegisterType<CpuStatService>().AsSelf().SingleInstance();
builder.RegisterType<PeriodicStatCollector>().AsSelf().SingleInstance();
builder.RegisterType<LastMessageCacheService>().AsSelf().SingleInstance();
2020-02-14 23:12:03 +00:00
builder.RegisterType<LoggerCleanService>().AsSelf().SingleInstance();
2020-01-26 00:27:45 +00:00
// Sentry stuff
builder.Register(_ => new Scope(null)).AsSelf().InstancePerLifetimeScope();
// Utils
builder.Register(c => new HttpClient
{
Timeout = TimeSpan.FromSeconds(5)
}).AsSelf().SingleInstance();
}
}
}