From c1d04b4d1ac833e917c266e16bbe6fae769bc230 Mon Sep 17 00:00:00 2001 From: Samuel <33796679+orchidalloy@users.noreply.github.com> Date: Wed, 14 Oct 2020 19:03:13 -0300 Subject: [PATCH] fix: Handle null PreferredLocale in rare cases (#1624) Sometimes Discord messes up and leaves a guild with a null PreferredLocale, causing an error to be thrown. This fixes that from Discord.Net's end even though it's Discord's fault. --- src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index d2d759bb36..160b91526a 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -381,7 +381,7 @@ internal void Update(ClientState state, Model model) Description = model.Description; PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault(); PreferredLocale = model.PreferredLocale; - PreferredCulture = new CultureInfo(PreferredLocale); + PreferredCulture = PreferredLocale == null ? null : new CultureInfo(PreferredLocale); if (model.Emojis != null) {