Command execution code rework and TypeConverters auto-scope fix (#2306)

* command execution rework and sync service scopes for typeconverters

* replace ValueTask with Task

* fix implementation bugs

Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
This commit is contained in:
Cenk Ergen
2022-11-22 14:05:26 +03:00
committed by GitHub
parent ea039b848c
commit 6869817184
11 changed files with 159 additions and 172 deletions

View File

@@ -103,7 +103,7 @@ namespace Discord.Interactions
public async Task<IResult> CreateModalAsync(IInteractionContext context, IServiceProvider services = null, bool throwOnMissingField = false)
{
if (context.Interaction is not IModalInteraction modalInteraction)
return ParseResult.FromError(InteractionCommandError.Unsuccessful, "Provided context doesn't belong to a Modal Interaction.");
return TypeConverterResult.FromError(InteractionCommandError.Unsuccessful, "Provided context doesn't belong to a Modal Interaction.");
services ??= EmptyServiceProvider.Instance;
@@ -120,7 +120,7 @@ namespace Discord.Interactions
if (!throwOnMissingField)
args[i] = input.DefaultValue;
else
return ParseResult.FromError(InteractionCommandError.BadArgs, $"Modal interaction is missing the required field: {input.CustomId}");
return TypeConverterResult.FromError(InteractionCommandError.BadArgs, $"Modal interaction is missing the required field: {input.CustomId}");
}
else
{
@@ -133,7 +133,7 @@ namespace Discord.Interactions
}
}
return ParseResult.FromSuccess(_initializer(args));
return TypeConverterResult.FromSuccess(_initializer(args));
}
}
}