Skip to content

Commit

Permalink
fix: Handle null PreferredLocale in rare cases (#1624)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hollowstrawberry committed Oct 14, 2020
1 parent 366ca9a commit c1d04b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit c1d04b4

Please sign in to comment.