Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace Discord.Interactions
{
Expand All @@ -29,6 +30,9 @@ protected virtual string GetLogString(IInteractionContext context)
public Task<IResult> ExecuteAsync(IInteractionContext context, IAutocompleteInteraction autocompleteInteraction, IParameterInfo parameter,
IServiceProvider services)
{
using IServiceScope scope = InteractionService._autoServiceScopes ? services?.CreateScope() : null;
services = InteractionService._autoServiceScopes ? scope?.ServiceProvider ?? EmptyServiceProvider.Instance : services;

switch (InteractionService._runMode)
{
case RunMode.Sync:
Expand All @@ -44,7 +48,7 @@ public Task<IResult> ExecuteAsync(IInteractionContext context, IAutocompleteInte
default:
throw new InvalidOperationException($"RunMode {InteractionService._runMode} is not supported.");
}

return Task.FromResult((IResult)ExecuteResult.FromSuccess());
}

Expand Down