Only log guilds and roles once after connecting

This commit is contained in:
Toastie 2024-12-27 19:39:52 +13:00
parent e3984ab968
commit 12337101b7
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
2 changed files with 9 additions and 0 deletions

View file

@ -18,6 +18,8 @@ namespace SupportChild;
public static class EventHandler public static class EventHandler
{ {
internal static bool hasLoggedGuilds = false;
public static Task OnReady(DiscordClient client, GuildDownloadCompletedEventArgs e) public static Task OnReady(DiscordClient client, GuildDownloadCompletedEventArgs e)
{ {
Logger.Log("Connected to Discord."); Logger.Log("Connected to Discord.");
@ -35,6 +37,12 @@ public static class EventHandler
public static async Task OnGuildAvailable(DiscordClient discordClient, GuildAvailableEventArgs e) public static async Task OnGuildAvailable(DiscordClient discordClient, GuildAvailableEventArgs e)
{ {
if (hasLoggedGuilds)
{
return;
}
hasLoggedGuilds = true;
Logger.Log("Found Discord server: " + e.Guild.Name + " (" + e.Guild.Id + ")"); Logger.Log("Found Discord server: " + e.Guild.Name + " (" + e.Guild.Id + ")");
if (SupportChild.commandLineArgs.serversToLeave.Contains(e.Guild.Id)) if (SupportChild.commandLineArgs.serversToLeave.Contains(e.Guild.Id))

View file

@ -224,6 +224,7 @@ internal static class SupportChild
client = clientBuilder.Build(); client = clientBuilder.Build();
Logger.Log("Connecting to Discord..."); Logger.Log("Connecting to Discord...");
EventHandler.hasLoggedGuilds = false;
await client.ConnectAsync(); await client.ConnectAsync();
return true; return true;
} }