diff --git a/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs b/src/Discord.Net.Interactions/Builders/ModuleBuilder.cs index 2fd28927d8..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; @@ -461,6 +462,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