Small change to Bot.cs to pinpoint the logging in hang issue

This commit is contained in:
Kwoth
2022-03-03 01:13:49 +01:00
parent 63ced029ab
commit 323699d103

View File

@@ -216,24 +216,20 @@ public sealed class Bot
private async Task LoginAsync(string token) private async Task LoginAsync(string token)
{ {
var clientReady = new TaskCompletionSource<bool>(); var clientReady = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
Task SetClientReady() async Task SetClientReady()
{ {
_ = Task.Run(async () => clientReady.TrySetResult(true);
try
{ {
clientReady.TrySetResult(true); foreach (var chan in await Client.GetDMChannelsAsync())
try await chan.CloseAsync();
{ }
foreach (var chan in await Client.GetDMChannelsAsync()) catch
await chan.CloseAsync(); {
} // ignored
catch }
{
// ignored
}
});
return Task.CompletedTask;
} }
//connect //connect
@@ -241,6 +237,7 @@ public sealed class Bot
try try
{ {
await Client.LoginAsync(TokenType.Bot, token); await Client.LoginAsync(TokenType.Bot, token);
Log.Information("Starting...");
await Client.StartAsync(); await Client.StartAsync();
} }
catch (HttpException ex) catch (HttpException ex)