Browse Source

Update EmbedBuilder.cs

Fixes a bug where 'EmbedBuilder.Length' will throw an exception of type 'System.NullReferenceException' when a field doesn't have a value.
pull/2345/head
Proddy GitHub 3 years ago
parent
commit
be8cadfbfd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs

+ 1
- 1
src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs View File

@@ -150,7 +150,7 @@ namespace Discord
int authorLength = Author?.Name?.Length ?? 0;
int descriptionLength = Description?.Length ?? 0;
int footerLength = Footer?.Text?.Length ?? 0;
int fieldSum = Fields.Sum(f => f.Name.Length + f.Value.ToString().Length);
int fieldSum = Fields.Sum(f => f.Name.Length + (string.IsNullOrEmpty(f.Value) ? 0 : f.Value.ToString().Length));

return titleLength + authorLength + descriptionLength + footerLength + fieldSum;
}


Loading…
Cancel
Save