-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandServiceCollectionExtensions.cs
More file actions
65 lines (58 loc) · 3.19 KB
/
Copy pathCommandServiceCollectionExtensions.cs
File metadata and controls
65 lines (58 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using Microsoft.Extensions.DependencyInjection;
using RustPlusBot.Discord;
using RustPlusBot.Features.Commands.Dispatching;
using RustPlusBot.Features.Commands.Handlers;
using RustPlusBot.Features.Commands.Help;
using RustPlusBot.Features.Commands.Hosting;
using RustPlusBot.Features.Commands.Leader;
using RustPlusBot.Features.Commands.Servers;
using RustPlusBot.Features.ItemData;
using RustPlusBot.Localization;
namespace RustPlusBot.Features.Commands;
/// <summary>DI registration for the in-game command framework.</summary>
public static class CommandServiceCollectionExtensions
{
/// <summary>Registers the dispatcher, cooldown, localizer, handlers, and hosted service.</summary>
/// <param name="services">The service collection to add to.</param>
/// <returns>The same service collection, for chaining.</returns>
public static IServiceCollection AddCommands(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);
services.AddSingleton<CommandCooldown>();
services.AddSingleton<BotUptime>();
services.AddRustPlusBotLocalization();
services.AddItemData();
services.AddScoped<ICommandHandler, MuteCommandHandler>();
services.AddScoped<ICommandHandler, UnmuteCommandHandler>();
services.AddScoped<ICommandHandler, UptimeCommandHandler>();
services.AddScoped<ICommandHandler, PopCommandHandler>();
services.AddScoped<ICommandHandler, WipeCommandHandler>();
services.AddScoped<ICommandHandler, TimeCommandHandler>();
services.AddScoped<ICommandHandler, OnlineCommandHandler>();
services.AddScoped<ICommandHandler, OfflineCommandHandler>();
services.AddScoped<ICommandHandler, TeamCommandHandler>();
services.AddScoped<ICommandHandler, SteamIdCommandHandler>();
services.AddScoped<ICommandHandler, AliveCommandHandler>();
services.AddScoped<ICommandHandler, AfkCommandHandler>();
services.AddScoped<ICommandHandler, ProxCommandHandler>();
services.AddScoped<ICommandHandler, CargoCommandHandler>();
services.AddScoped<ICommandHandler, HeliCommandHandler>();
services.AddScoped<ICommandHandler, ChinookCommandHandler>();
services.AddScoped<ICommandHandler, EventsCommandHandler>();
services.AddScoped<ICommandHandler, SmallCommandHandler>();
services.AddScoped<ICommandHandler, LargeCommandHandler>();
services.AddScoped<ICommandHandler, ItemCommandHandler>();
services.AddScoped<ICommandHandler, RecycleCommandHandler>();
services.AddScoped<ICommandHandler, CraftCommandHandler>();
services.AddScoped<ICommandHandler, ResearchCommandHandler>();
services.AddScoped<CommandDispatcher>();
services.AddHostedService<CommandsHostedService>();
// Discord surfaces (3c): help renderer, leader service, and the interaction modules.
services.AddScoped<HelpEmbedRenderer>();
services.AddScoped<LeaderService>();
services.AddScoped<ServerResolver>();
services.AddScoped<ServerQueryService>();
services.AddSingleton(new InteractionModuleAssembly(typeof(CommandServiceCollectionExtensions).Assembly));
return services;
}
}