From 5adb4b08dc3eaab2c48056c444214db750123576 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Fri, 1 Dec 2023 08:41:05 +0000 Subject: [PATCH] fix issue where bot would explode on discord reconnect --- SecondBotEvents/Services/DiscordService.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SecondBotEvents/Services/DiscordService.cs b/SecondBotEvents/Services/DiscordService.cs index 7d4c122..f09027e 100644 --- a/SecondBotEvents/Services/DiscordService.cs +++ b/SecondBotEvents/Services/DiscordService.cs @@ -578,7 +578,14 @@ namespace SecondBotEvents.Services CleanChannel(channel); } WantedTextChannels.Remove(channel.Name); + if (ChannelMap.ContainsKey(channel.Name) == false) + { + ChannelMap[channel.Name] = channel.Id; + return; + } ChannelMap.Add(channel.Name, channel.Id); + + } List WantedCategoryChannels = new List @@ -594,6 +601,11 @@ namespace SecondBotEvents.Services continue; } WantedCategoryChannels.Remove(category.Name); + if (ChannelMap.ContainsKey(category.Name) == false) + { + ChannelMap[category.Name] = category.Id; + return; + } CategoryMap.Add(category.Name, category.Id); } foreach(String a in WantedCategoryChannels)