Skip to content

Commit 47801bb

Browse files
committed
fix service provider things
1 parent 13ddb5a commit 47801bb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

DisCatSharp.Extensions.TwoFactorCommands/ExtensionMethods.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ public static TwoFactorExtension UseTwoFactor(this DiscordClient client, TwoFact
4646
if (client.GetExtension<TwoFactorExtension>() != null)
4747
throw new InvalidOperationException("TwoFactor is already enabled for that client.");
4848

49+
cfg ??= new TwoFactorConfiguration();
4950
cfg.ServiceProvider ??= client.ServiceProvider ?? new ServiceCollection().BuildServiceProvider(true);
5051

51-
var cnext = new TwoFactorExtension(cfg);
52-
client.AddExtension(cnext);
53-
return cnext;
52+
var tfe = new TwoFactorExtension(cfg);
53+
client.AddExtension(tfe);
54+
return tfe;
5455
}
5556

5657
/// <summary>
@@ -66,10 +67,10 @@ public static async Task<IReadOnlyDictionary<int, TwoFactorExtension>> UseTwoFac
6667

6768
foreach (var shard in client.ShardClients.Select(xkvp => xkvp.Value))
6869
{
69-
var cnext = shard.GetExtension<TwoFactorExtension>();
70-
cnext ??= shard.UseTwoFactor(cfg);
70+
var tfe = shard.GetExtension<TwoFactorExtension>();
71+
tfe ??= shard.UseTwoFactor(cfg);
7172

72-
modules[shard.ShardId] = cnext;
73+
modules[shard.ShardId] = tfe;
7374
}
7475

7576
return new ReadOnlyDictionary<int, TwoFactorExtension>(modules);

0 commit comments

Comments
 (0)