Skip to content

Commit 087718b

Browse files
Fix accessing disposed scope in CommandParallelQueueWorker
1 parent c553631 commit 087718b

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/Kattbot/Infrastructure/ServiceCollectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public static void AddDiscordClient(this IServiceCollection services, IConfigura
3636

3737
var clientBuilder = DiscordClientBuilder.CreateDefault(botToken, DiscordIntents.All, services);
3838

39+
clientBuilder.ConfigureExtraFeatures(cfg => { cfg.LogUnknownEvents = false; });
40+
3941
clientBuilder.SetLogLevel(logLevel);
4042

4143
clientBuilder.RegisterCommands(configuration);

src/Kattbot/Workers/CommandQueueWorker.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
3939
command.GetType().Name,
4040
_channel.Reader.Count);
4141

42-
using var scope = _scopeFactory.CreateScope();
43-
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
44-
45-
_ = Task.Run(() => mediator.Send(command, stoppingToken), stoppingToken);
42+
_ = Task.Run(
43+
async () =>
44+
{
45+
using var scope = _scopeFactory.CreateScope();
46+
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
47+
await mediator.Send(command, stoppingToken);
48+
},
49+
stoppingToken);
4650
}
4751
}
4852
catch (TaskCanceledException)

src/Kattbot/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"Kattbot": {
1111
"ConnectionString": "Server=host.docker.internal:5433;Database=kattbot-dev;User Id=kattbot;Password=hunter2",
12-
"CommandPrefix": "!",
12+
"CommandPrefix": ";;",
1313
"AlternateCommandPrefix": "kd",
1414
"ErrorLogGuildId": "1411437458062835809",
1515
"ErrorLogChannelId": "1411441087997808750"

0 commit comments

Comments
 (0)