diff --git a/src/Octobot.cs b/src/Octobot.cs index 2648338..2e810ed 100644 --- a/src/Octobot.cs +++ b/src/Octobot.cs @@ -2,11 +2,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Octobot.Commands; using Octobot.Commands.Events; using Octobot.Services; using Octobot.Services.Update; -using Remora.Commands.Extensions; using Remora.Discord.API.Abstractions.Gateway.Commands; using Remora.Discord.API.Abstractions.Objects; using Remora.Discord.API.Objects; @@ -14,8 +12,8 @@ using Remora.Discord.Caching.Extensions; using Remora.Discord.Caching.Services; using Remora.Discord.Commands.Extensions; using Remora.Discord.Commands.Services; +using Remora.Discord.Extensions.Extensions; using Remora.Discord.Gateway; -using Remora.Discord.Gateway.Extensions; using Remora.Discord.Hosting.Extensions; using Remora.Rest.Core; using Serilog.Extensions.Logging; @@ -82,6 +80,8 @@ public sealed class Octobot // Init .AddDiscordCaching() .AddDiscordCommands(true, false) + .AddRespondersFromAssembly(typeof(Octobot).Assembly) + .AddCommandGroupsFromAssembly(typeof(Octobot).Assembly) // Slash command event handlers .AddPreparationErrorEvent() .AddPostExecutionEvent() @@ -91,25 +91,7 @@ public sealed class Octobot .AddHostedService(provider => provider.GetRequiredService()) .AddHostedService() .AddHostedService() - .AddHostedService() - // Slash commands - .AddCommandTree() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup() - .WithCommandGroup(); - var responderTypes = typeof(Octobot).Assembly - .GetExportedTypes() - .Where(t => t.IsResponder()); - foreach (var responderType in responderTypes) - { - services.AddResponder(responderType); - } + .AddHostedService(); } ).ConfigureLogging( c => c.AddConsole()