From 56a92830602e692340166e8ef1506781017f4553 Mon Sep 17 00:00:00 2001 From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> Date: Sun, 28 Nov 2021 19:48:02 +0300 Subject: [PATCH] Fix NRE on service providerless command execution (#322) * fix not set to an instance of an object exception for service providerless command execution --- src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs b/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs index c31d09f60..f9fdb6e38 100644 --- a/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs +++ b/src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs @@ -132,13 +132,13 @@ namespace Discord.Interactions case RunMode.Sync: { using var scope = services?.CreateScope(); - return await ExecuteInternalAsync(context, args, scope.ServiceProvider ?? EmptyServiceProvider.Instance).ConfigureAwait(false); + return await ExecuteInternalAsync(context, args, scope?.ServiceProvider ?? EmptyServiceProvider.Instance).ConfigureAwait(false); } case RunMode.Async: _ = Task.Run(async () => { using var scope = services?.CreateScope(); - await ExecuteInternalAsync(context, args, scope.ServiceProvider ?? EmptyServiceProvider.Instance).ConfigureAwait(false); + await ExecuteInternalAsync(context, args, scope?.ServiceProvider ?? EmptyServiceProvider.Instance).ConfigureAwait(false); }); break; default: