AutoServiceScopes strikes again (#3072)

This commit is contained in:
Mihail Gribkov
2025-03-02 00:55:59 +03:00
committed by GitHub
parent 6fb2a29351
commit d71fcb1a42

View File

@@ -30,9 +30,6 @@ namespace Discord.Interactions
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:
@@ -57,6 +54,14 @@ namespace Discord.Interactions
{
try
{
await using var scope = InteractionService._autoServiceScopes
? services?.CreateAsyncScope()
: null;
services = (InteractionService._autoServiceScopes
? scope?.ServiceProvider
: services) ?? EmptyServiceProvider.Instance;
var result = await GenerateSuggestionsAsync(context, autocompleteInteraction, parameter, services).ConfigureAwait(false);
if (result.IsSuccess)