Remove extraneous log messages

In particular, these changes filter out the reporting of any errors
occurring during the bot shutdown process.
This commit is contained in:
Noi 2023-09-04 16:15:48 -07:00
parent 1aaca8545e
commit b9b057e1f1
3 changed files with 6 additions and 3 deletions

View file

@ -57,7 +57,11 @@ class AutoUserDownload : BackgroundService {
await Task.Delay(200, CancellationToken.None); // Delay a bit (reduces the possibility of hanging, somehow). await Task.Delay(200, CancellationToken.None); // Delay a bit (reduces the possibility of hanging, somehow).
var dl = guild.DownloadUsersAsync(); var dl = guild.DownloadUsersAsync();
dl.Wait((int)RequestTimeout.TotalMilliseconds / 2, token); try {
dl.Wait((int)RequestTimeout.TotalMilliseconds / 2, token);
} catch (Exception) { }
if (token.IsCancellationRequested) return; // Skip all reporting, error logging on cancellation
if (dl.IsFaulted) { if (dl.IsFaulted) {
Log("Exception thrown by download task: " + dl.Exception); Log("Exception thrown by download task: " + dl.Exception);
break; break;

View file

@ -94,6 +94,7 @@ public sealed class ShardInstance : IDisposable {
return Task.CompletedTask; return Task.CompletedTask;
} }
if (arg.Exception is TaskCanceledException) return Task.CompletedTask; // We don't ever need to know these...
Log("Discord.Net exception", $"{arg.Exception.GetType().FullName}: {arg.Exception.Message}"); Log("Discord.Net exception", $"{arg.Exception.GetType().FullName}: {arg.Exception.Message}");
} }

View file

@ -61,8 +61,6 @@ class ShardManager : IDisposable {
if (!Task.WhenAll(shardDisposes).Wait(30000)) { if (!Task.WhenAll(shardDisposes).Wait(30000)) {
Log("Warning: Not all shards terminated cleanly after 30 seconds. Continuing..."); Log("Warning: Not all shards terminated cleanly after 30 seconds. Continuing...");
} }
Log($"Uptime: {Program.BotUptime}");
} }
private void Log(string message) => Program.Log(nameof(ShardManager), message); private void Log(string message) => Program.Log(nameof(ShardManager), message);