Add log message

This commit is contained in:
Noi 2022-03-21 23:33:24 -07:00
parent c280904cb8
commit 2a1478fb0b

View file

@ -16,14 +16,18 @@ class AutoUserDownload : BackgroundService {
// ...and if the guild contains any user data // ...and if the guild contains any user data
var mustFetch = db.UserEntries.Where(e => incompleteCaches.Contains(e.GuildId)).Select(e => e.GuildId).Distinct(); var mustFetch = db.UserEntries.Where(e => incompleteCaches.Contains(e.GuildId)).Select(e => e.GuildId).Distinct();
int processed = 0;
foreach (var item in mustFetch) { foreach (var item in mustFetch) {
// May cause a disconnect in certain situations. Cancel all further attempts until the next pass if it happens. // May cause a disconnect in certain situations. Cancel all further attempts until the next pass if it happens.
if (ShardInstance.DiscordClient.ConnectionState != ConnectionState.Connected) return; if (ShardInstance.DiscordClient.ConnectionState != ConnectionState.Connected) break;
var guild = ShardInstance.DiscordClient.GetGuild((ulong)item); var guild = ShardInstance.DiscordClient.GetGuild((ulong)item);
if (guild == null) continue; // A guild disappeared...? if (guild == null) continue; // A guild disappeared...?
await guild.DownloadUsersAsync().ConfigureAwait(false); // We're already on a seperate thread, no need to use Task.Run await guild.DownloadUsersAsync().ConfigureAwait(false); // We're already on a seperate thread, no need to use Task.Run
await Task.Delay(200, CancellationToken.None).ConfigureAwait(false); // Must delay, or else it seems to hang... await Task.Delay(200, CancellationToken.None).ConfigureAwait(false); // Must delay, or else it seems to hang...
processed++;
} }
if (processed > 0) Log($"Explicit user list request processed for {processed} guild(s).");
} }
} }