From dc01c8c3f85a060091593de5ddb44afb25f03fb0 Mon Sep 17 00:00:00 2001 From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com> Date: Sat, 16 Nov 2024 20:31:59 +0300 Subject: [PATCH 1/2] Update ModuleBuilder.cs --- src/Discord.Net.Interactions/Builders/ModuleBuilder.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs index 2fd28927d8..a2f5abcf8d 100644 --- a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs @@ -461,6 +461,10 @@ internal ModuleInfo Build(InteractionService interactionService, IServiceProvide { if (TypeInfo is not null && ModuleClassBuilder.IsValidModuleDefinition(TypeInfo)) { + using var scope = services?.CreateScope(); + if (interactionService._autoServiceScopes) + services = scope?.ServiceProvider ?? EmptyServiceProvider.Instance; + var instance = ReflectionUtils.CreateObject(TypeInfo, interactionService, services); try From d3dd9fc4dcf28fbaecf337cf5b17f527f0267750 Mon Sep 17 00:00:00 2001 From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com> Date: Sat, 16 Nov 2024 20:35:04 +0300 Subject: [PATCH 2/2] oh right the `using` --- src/Discord.Net.Interactions/Builders/ModuleBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs index a2f5abcf8d..6b4883f1bd 100644 --- a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs +++ b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs @@ -1,3 +1,4 @@ +using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Reflection;