From 12337101b79b695557a14294a9b9ea5cc6e3b290 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 27 Dec 2024 19:39:52 +1300 Subject: [PATCH] Only log guilds and roles once after connecting --- EventHandler.cs | 8 ++++++++ SupportChild.cs | 1 + 2 files changed, 9 insertions(+) diff --git a/EventHandler.cs b/EventHandler.cs index fb8fde1..e3e3fd6 100644 --- a/EventHandler.cs +++ b/EventHandler.cs @@ -18,6 +18,8 @@ namespace SupportChild; public static class EventHandler { + internal static bool hasLoggedGuilds = false; + public static Task OnReady(DiscordClient client, GuildDownloadCompletedEventArgs e) { Logger.Log("Connected to Discord."); @@ -35,6 +37,12 @@ public static class EventHandler 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 + ")"); if (SupportChild.commandLineArgs.serversToLeave.Contains(e.Guild.Id)) diff --git a/SupportChild.cs b/SupportChild.cs index b719148..183ae85 100644 --- a/SupportChild.cs +++ b/SupportChild.cs @@ -224,6 +224,7 @@ internal static class SupportChild client = clientBuilder.Build(); Logger.Log("Connecting to Discord..."); + EventHandler.hasLoggedGuilds = false; await client.ConnectAsync(); return true; }