Skip to content

Commit

Permalink
Fix startup downloading exceptions are not logged
Browse files Browse the repository at this point in the history
  • Loading branch information
gehongyan committed Jan 7, 2024
1 parent 32f8161 commit c222f60
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions src/Kook.Net.WebSocket/KookSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,13 +1777,49 @@ await _gatewayLogger.WarningAsync($"Unknown Event Type ({gatewayEvent.Type}). Pa
// Download user list if enabled
if (_baseConfig.AlwaysDownloadUsers)
_ = DownloadUsersAsync(Guilds.Where(x => x.IsAvailable && x.HasAllMembers is not true), RequestOptions.Default);
{
_ = Task.Run(async () =>
{
try
{
await DownloadUsersAsync(Guilds.Where(x => x.IsAvailable && x.HasAllMembers is not true));
}
catch (Exception ex)
{
await _gatewayLogger.WarningAsync("Downloading users failed", ex).ConfigureAwait(false);
}
});
}
if (_baseConfig.AlwaysDownloadVoiceStates)
_ = DownloadVoiceStatesAsync(Guilds.Where(x => x.IsAvailable), RequestOptions.Default);
{
_ = Task.Run(async () =>
{
try
{
await DownloadVoiceStatesAsync(Guilds.Where(x => x.IsAvailable));
}
catch (Exception ex)
{
await _gatewayLogger.WarningAsync("Downloading voice states failed", ex).ConfigureAwait(false);
}
});
}
if (_baseConfig.AlwaysDownloadBoostSubscriptions)
_ = DownloadBoostSubscriptionsAsync(Guilds.Where(x => x.IsAvailable), RequestOptions.Default);
{
_ = Task.Run(async () =>
{
try
{
await DownloadBoostSubscriptionsAsync(Guilds.Where(x => x.IsAvailable));
}
catch (Exception ex)
{
await _gatewayLogger.WarningAsync("Downloading boost subscriptions failed", ex).ConfigureAwait(false);
}
});
}
await TimedInvokeAsync(_readyEvent, nameof(Ready)).ConfigureAwait(false);
await _gatewayLogger.InfoAsync("Ready").ConfigureAwait(false);
Expand Down

0 comments on commit c222f60

Please sign in to comment.